-
Notifications
You must be signed in to change notification settings - Fork 17
testing: reorg of test infra for maintainability and scalability #342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like using the "markers" feature of pytest. I have some work (not yet PR-ed) where I employ one new marker "wxapp" to mark the tests that require the wx.App object, and I have a use-case for running all unit tests except those that require wx.App object. |
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the use of conftest.py for shared pytest fixtures. I use that in a branch that I have not yet PR-ed. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| """ | ||
| /tests/conftest.py | ||
|
|
||
| Shared pytest fixtures for LabGym tests | ||
| """ | ||
|
|
||
| # Standard library imports | ||
| import sys | ||
|
|
||
| # Related third party imports | ||
| import pytest | ||
|
|
||
| @pytest.fixture(scope="session") | ||
| def wx_app(): | ||
| from LabGym.ui.gui import wxutils | ||
| import wx | ||
| app = wx.App() | ||
| yield app | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def mock_argv(monkeypatch): | ||
| monkeypatch.setattr(sys, 'argv', ['LabGym']) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def sample_greyscale_frame(): | ||
| import numpy as np | ||
| import cv2 | ||
| frame = np.full((100, 100), 200, dtype = np.uint8) | ||
| cv2.circle(frame, (50, 50), 15, 50, -1) | ||
| return frame | ||
|
|
||
| @pytest.fixture | ||
| def sample_video_frames(): | ||
| import numpy as np | ||
| import cv2 | ||
| frames = [] | ||
|
|
||
| for i in range(60): | ||
| frame = np.full((100, 100), 200, dtype = np.uint8) | ||
| cv2.circle(frame, (20 + i % 60, 50), 15, 50, -1) | ||
| frames.append(frame) | ||
|
|
||
| return frames |
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm prepared for this file to be eliminated, it falls into the category of personal-developer-tooling and shouldn't clutter the project. At one point I thought it would be more generally useful, but, that's looking unlikely. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this line be simply eliminated? I think the nox install of pytest was previously necessary, because pytest wasn't in pyproject.toml. But now it is. And nothing depends on "coverage", right?