From: brentru Date: Tue, 21 May 2024 17:46:43 +0000 (-0400) Subject: move tests to pyutest test/ dir X-Git-Tag: 8.39.2^2~5 X-Git-Url: https://git.ayoreis.com/Adafruit_Blinka-hackapet.git/commitdiff_plain/1baf46a1c2639847dc9a396923658dbe106656e0 move tests to pyutest test/ dir --- diff --git a/examples/generic_aio.py b/tests/test_generic_agnostic_board_analogio.py similarity index 84% rename from examples/generic_aio.py rename to tests/test_generic_agnostic_board_analogio.py index 8e6c9c1..07c8424 100644 --- a/examples/generic_aio.py +++ b/tests/test_generic_agnostic_board_analogio.py @@ -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() diff --git a/examples/generic_dio.py b/tests/test_generic_agnostic_board_digitalio.py similarity index 100% rename from examples/generic_dio.py rename to tests/test_generic_agnostic_board_digitalio.py diff --git a/examples/generic_i2c.py b/tests/test_generic_agnostic_board_i2c.py similarity index 82% rename from examples/generic_i2c.py rename to tests/test_generic_agnostic_board_i2c.py index 61ca8f0..6a3b5b9 100644 --- a/examples/generic_i2c.py +++ b/tests/test_generic_agnostic_board_i2c.py @@ -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)