Decrease the number of tests for RateDetection#423
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR optimizes the test suite by marking slow RateDetection tests with a @pytest.mark.slow decorator and configuring pytest to skip these tests by default, while ensuring they still run during release workflows.
Key changes:
- Added pytest configuration to handle slow test markers and skip them by default
- Marked four parameterized RateDetection test functions as slow
- Updated the release workflow to explicitly run slow tests with the
--runslowflag
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/test_rate_detection.py | Added @pytest.mark.slow decorators to four parameterized test functions |
| tests/conftest.py | Added pytest configuration for handling slow test markers and skipping logic |
| .github/workflows/release_github.yml | Updated pytest command to include --runslow flag for release testing |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Comment on lines
+25
to
+33
| def pytest_addoption(parser: pytest.Parser): | ||
| parser.addoption("--runslow", action="store_true", default=False, help="run tests marked as slow") | ||
|
|
||
|
|
||
| def pytest_configure(config: pytest.Config): | ||
| config.addinivalue_line("markers", "slow: mark test as slow to run") | ||
|
|
||
|
|
||
| def pytest_collection_modifyitems(config: pytest.Config, items: list[pytest.Item]): |
There was a problem hiding this comment.
The pytest hook functions lack docstrings explaining their purpose and behavior. Consider adding docstrings to document what each hook does, especially the collection modification logic.
Suggested change
| def pytest_addoption(parser: pytest.Parser): | |
| parser.addoption("--runslow", action="store_true", default=False, help="run tests marked as slow") | |
| def pytest_configure(config: pytest.Config): | |
| config.addinivalue_line("markers", "slow: mark test as slow to run") | |
| def pytest_collection_modifyitems(config: pytest.Config, items: list[pytest.Item]): | |
| def pytest_addoption(parser: pytest.Parser): | |
| """Add a command-line option '--runslow' to enable running tests marked as slow.""" | |
| parser.addoption("--runslow", action="store_true", default=False, help="run tests marked as slow") | |
| def pytest_configure(config: pytest.Config): | |
| """Register the 'slow' marker for tests.""" | |
| config.addinivalue_line("markers", "slow: mark test as slow to run") | |
| def pytest_collection_modifyitems(config: pytest.Config, items: list[pytest.Item]): | |
| """ | |
| Skip tests marked as 'slow' unless the '--runslow' option is specified. | |
| This hook checks for the presence of the '--runslow' command-line option. | |
| If it is not set, all tests marked with 'slow' are skipped. | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RateDetection tests are slow. This PR marks them as slow and makes it they don't by default, e.g., with each push to a PR branch. However, before release, all slow tests are run in all versions of Python.