pytest_temp_sensor_example.py 859 B

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