Skip to content

Add hardware testing capability to test suite#58

Open
ogeesan wants to merge 26 commits into
devfrom
39-protocol-and-hardware
Open

Add hardware testing capability to test suite#58
ogeesan wants to merge 26 commits into
devfrom
39-protocol-and-hardware

Conversation

@ogeesan
Copy link
Copy Markdown
Collaborator

@ogeesan ogeesan commented Apr 21, 2026

As a developer, I want tests to be able to use a connected Bpod state machine to run.

  • Pytest CLI arguments to configure hardware testing added.
  • Pytest fixture for connecting to Bpod state machine hardware added.
  • Coveralls has been uncommented, and now runs again.

just test-hardware will 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, or just test-hardware which runs the software and hardware tests. just test-hardware can 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.hardware decorator to indicate the test should only be run when connected to hardware, and the bpod_rig fixture returns a bpod_core.bpod.Bpod object connected to machine.

@ogeesan ogeesan self-assigned this Apr 21, 2026
@ogeesan ogeesan changed the title 39 protocol and hardware testing Add hardware testing capability to test suite Apr 22, 2026
@ogeesan ogeesan marked this pull request as ready for review April 22, 2026 13:50
@ogeesan ogeesan requested a review from austin2118ace April 22, 2026 13:50
@ogeesan ogeesan linked an issue Apr 22, 2026 that may be closed by this pull request
4 tasks
Copy link
Copy Markdown
Collaborator

@austin2118ace austin2118ace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cursory look finished

Comment thread tests/conftest.py Outdated
Comment thread tests/conftest.py Outdated
Comment thread tests/conftest.py
Comment thread tests/conftest.py
Comment thread tests/conftest.py Outdated


@pytest.fixture(scope="session")
def bpod_rig(request: pytest.FixtureRequest) -> Generator[Bpod, None, None]:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why a separate fixture and hook? hook doesn't seem to do anything but print info.

should the fixture also have try/except logic?

Copy link
Copy Markdown
Collaborator Author

@ogeesan ogeesan Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a few reasons for the hook.

  • It attempts connection to bpod_core.bpod.Bpod with the same parameters that the fixture will use, verifying that it works. If it fails we pytest.exit because 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.

@ogeesan ogeesan mentioned this pull request Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create test/example protocol

2 participants