Skip to content

Commit 8b2bbd5

Browse files
dccoteclaude
andcommitted
Skip LabJack hardware tests when the exodriver library is absent
TestLabjackDevice.setUp only skipped when initializeDevice() raised u3.LabJackException ("library installed, no device attached"). On a host that has LabJackPython but not the native exodriver shared library, the call instead raises AttributeError ('NoneType' object has no attribute 'LJUSB_OpenDevice', because LabJackPython's staticLib is None). That was not caught, so all 21 real-hardware tests failed instead of skipping. This surfaced once CI started running the suite: LabJackPython installs as a declared dependency, but the exodriver native library is not present on the runners, so every matrix job went red. Broaden the skip guard to treat AttributeError as another "no hardware" signature, honouring the project rule that hardware tests must skipTest() when no device is attached rather than fail. Unexpected causes still re-raise. No change in behaviour where a real LabJack is connected. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 680f618 commit 8b2bbd5

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

hardwarelibrary/tests/testLabjackU3.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ def setUp(self):
2929
self.device.initializeDevice()
3030
except PhysicalDevice.UnableToInitialize as err:
3131
cause = err.args[0] if err.args else None
32-
if isinstance(cause, u3.LabJackException):
32+
# No device attached raises u3.LabJackException; a host without the
33+
# native LabJack exodriver library raises AttributeError, because
34+
# LabJackPython's staticLib is None. Either way there is no hardware
35+
# to exercise, so skip rather than fail.
36+
if isinstance(cause, (u3.LabJackException, AttributeError)):
3337
self.skipTest("No Labjack connected")
3438
raise
3539

0 commit comments

Comments
 (0)