]> Repositories - Adafruit_Blinka-hackapet.git/commitdiff
move tests to pyutest test/ dir
authorbrentru <brent@adafruit.com>
Tue, 21 May 2024 17:46:43 +0000 (13:46 -0400)
committerbrentru <brent@adafruit.com>
Tue, 21 May 2024 17:46:43 +0000 (13:46 -0400)
tests/test_generic_agnostic_board_analogio.py [moved from examples/generic_aio.py with 84% similarity]
tests/test_generic_agnostic_board_digitalio.py [moved from examples/generic_dio.py with 100% similarity]
tests/test_generic_agnostic_board_i2c.py [moved from examples/generic_i2c.py with 82% similarity]

similarity index 84%
rename from examples/generic_aio.py
rename to tests/test_generic_agnostic_board_analogio.py
index 8e6c9c12e0280a32ff90025cf9f3101b309bdf92..07c8424ced2039613d0f7385047830b3fea2a586 100644 (file)
@@ -99,12 +99,13 @@ def test_Ax_INPUT_WAVE_SINE():
     pin_sine_wave = analogio.AnalogIn(board.Ax_INPUT_WAVE_SINE)
 
     # Run through the sine wave once
-    for i in range(len(sine_wave)):
-        assert pin_sine_wave.value == sine_wave[i]
+    for i, expected_value in enumerate(sine_wave):
+        assert pin_sine_wave.value == expected_value
+
 
     # Run through the sine wave again to ensure it loops back correctly
-    for i in range(len(sine_wave)):
-        assert pin_sine_wave.value == sine_wave[i]
+    for i, expected_value in enumerate(sine_wave):
+        assert pin_sine_wave.value == expected_value
 
     pin_sine_wave.deinit()
 
@@ -112,14 +113,15 @@ def test_Ax_INPUT_WAVE_SINE():
 def test_Ax_INPUT_WAVE_SAW():
     """Test sawtooth wave from pin Ax_INPUT_WAVE_SAW"""
     assert board.board_id == "GENERIC_AGNOSTIC_BOARD"
-    pin_sine_wave = analogio.AnalogIn(board.Ax_INPUT_WAVE_SAW)
+    pin_saw_wave = analogio.AnalogIn(board.Ax_INPUT_WAVE_SAW)
 
     # Run through the sine wave once
     for i in range(len(sawtooth_wave)):
-        assert pin_sine_wave.value == sawtooth_wave[i]
+        assert pin_saw_wave.value == sawtooth_wave[i]
 
     # Run through the sine wave again to ensure it loops back correctly
     for i in range(len(sawtooth_wave)):
-        assert pin_sine_wave.value == sawtooth_wave[i]
+        assert pin_saw_wave.value == sawtooth_wave[i]
 
-    pin_sine_wave.deinit()
+
+    pin_saw_wave.deinit()
similarity index 82%
rename from examples/generic_i2c.py
rename to tests/test_generic_agnostic_board_i2c.py
index 61ca8f03d6053dded6477bbf48afa744c788645c..6a3b5b9deb20d0fed5a617dab6324e0105c9deca 100644 (file)
@@ -1,9 +1,9 @@
 # SPDX-FileCopyrightText: 2024 Brent Rubell for Adafruit Industries
 #
 # SPDX-License-Identifier: MIT
-import pytest
+import pytest # pylint: disable=unused-import
 import busio
-from board import *
+from board import SCL, SDA
 
 def test_i2c_scan_random():
     i2c = busio.I2C(SCL, SDA)