pytest_temp_sensor_example.py 817 B

1234567891011121314151617181920
  1. # SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
  2. # SPDX-License-Identifier: CC0-1.0
  3. import pytest
  4. from pytest_embedded.dut import Dut
  5. @pytest.mark.esp32s2
  6. @pytest.mark.esp32c3
  7. @pytest.mark.esp32s3
  8. @pytest.mark.generic
  9. def test_temp_sensor_example(dut: Dut) -> None:
  10. dut.expect_exact('Install temperature sensor')
  11. dut.expect_exact('Enable temperature sensor')
  12. dut.expect_exact('Read temperature')
  13. temp_value = dut.expect(r'Temperature value (\d+\.\d+) .*', timeout=5)
  14. # Because the example test only run in the normal temperature environment. So this assert range is meaningful
  15. assert 0 < float(temp_value.group(1).decode('utf8')) < 50
  16. temp_value = dut.expect(r'Temperature value (\d+\.\d+) .*', timeout=5)
  17. assert 0 < float(temp_value.group(1).decode('utf8')) < 50