pytest_temp_sensor_example.py 838 B

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