Skip to content
This repository was archived by the owner on Nov 7, 2024. It is now read-only.

Commit d2e4f51

Browse files
committed
Improved logic to detect what the board response test is running on.
Simplified the logic used to decide whether the test_board_responses are running on a microcontroller or a Raspberry Pi, and if on a Pi, whether to skip the tests.
1 parent cb2fdc5 commit d2e4f51

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

tests/test_board_responses.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,24 @@
1515
# Therefore skip this file.
1616
# pylint: skip-file
1717

18-
import os
1918
import time
2019

21-
# If the board is attached to the Raspberry Pi pytest will import
2220
try:
23-
sensor_attached = os.environ["SENSOR_ATTACHED"]
24-
import pytest
21+
import pytest # If this works, we're on a Raspberry Pi
22+
import os
2523
from CircuitPython_AS3935 import biffobear_as3935 as as3935
26-
import board
27-
except (KeyError, AttributeError):
28-
# env not set, so try to skip tests (exception if not attached to Pi)
29-
try:
30-
pytestmark = pytest.mark.skipfile(reason="No as3935 board connected.")
31-
except NameError:
32-
# No pytest, so not attached to Pi
33-
pass
24+
25+
# try:
26+
# sensor_attached = os.environ["SENSOR_ATTACHED"]
27+
# except (KeyError, AttributeError):
28+
pytestmark = pytest.mark.skip(reason="No as3935 board connected.")
29+
print("hello world")
30+
3431
except ImportError:
35-
# Sensor attached to an ItsyBitsyM4
32+
# Deduce that pytest didn't import, so we are running on a board
3633
import biffobear_as3935 as as3935
37-
import board
34+
35+
import board
3836

3937
device = None
4038

0 commit comments

Comments
 (0)