Add hardware testing capability to test suite#58
Conversation
austin2118ace
left a comment
There was a problem hiding this comment.
cursory look finished
|
|
||
|
|
||
| @pytest.fixture(scope="session") | ||
| def bpod_rig(request: pytest.FixtureRequest) -> Generator[Bpod, None, None]: |
There was a problem hiding this comment.
why a separate fixture and hook? hook doesn't seem to do anything but print info.
should the fixture also have try/except logic?
There was a problem hiding this comment.
There's a few reasons for the hook.
- It attempts connection to
bpod_core.bpod.Bpodwith the same parameters that the fixture will use, verifying that it works. If it fails wepytest.exitbecause none of the hardware tests are going to work if we can't connect. - It prints the info about the connection to terminal (assuming that's where users troubleshooting things would copy/paste their log info).
We could change bpod_rig fixture to be on a function basis in the future, so the session start hook would be useful in that situation. But right now since it's a session fixture we could not use the hook at all.
The fixture could an except that calls pytest.exist if it fails to connect, which would produce the same behaviour as what is currently done (exit tests if connection failed).
But on assessment, I think that the hook isn't necessary. If we do move to function scoped fixtures then maybe we do need the hook, but while it's session scoped we don't. I've changed it to use an autouse=True fixture.
just test-hardwarewill run Pytest with a flag that connects it to a Bpod machine, and then runs tests that require hardware connection (that are normally skipped).Now, tests can be run with
just test, which runs only the software tests, orjust test-hardwarewhich runs the software and hardware tests.just test-hardwarecan take some additional arguments to specify which Bpod state machine to use in the tests.When writing tests a developer can use the
@pytest.mark.hardwaredecorator to indicate the test should only be run when connected to hardware, and thebpod_rigfixture returns abpod_core.bpod.Bpodobject connected to machine.