pytest_temp_sensor_example.py 885 B

1234567891011121314151617181920212223
  1. # SPDX-FileCopyrightText: 2022-2023 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.esp32c2
  9. @pytest.mark.esp32c6
  10. @pytest.mark.esp32h2
  11. @pytest.mark.generic
  12. def test_temp_sensor_example(dut: Dut) -> None:
  13. dut.expect_exact('Install temperature sensor')
  14. dut.expect_exact('Enable temperature sensor')
  15. dut.expect_exact('Read temperature')
  16. temp_value = dut.expect(r'Temperature value (\d+\.\d+) .*', timeout=5)
  17. # Because the example test only run in the normal temperature environment. So this assert range is meaningful
  18. assert 0 < float(temp_value.group(1).decode('utf8')) < 50
  19. temp_value = dut.expect(r'Temperature value (\d+\.\d+) .*', timeout=5)
  20. assert 0 < float(temp_value.group(1).decode('utf8')) < 50