-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use full-suite conditional params in tests.
- Loading branch information
Showing
3 changed files
with
74 additions
and
26 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import pytest | ||
import os | ||
|
||
# Global FULL_SUITE flag to control which parameter sets are used | ||
FULL_SUITE = None | ||
|
||
def pytest_addoption(parser): | ||
"""Add the --full-suite command-line option for pytest.""" | ||
parser.addoption( | ||
"--full-suite", action="store_true", default=False, help="Run the full test suite" | ||
) | ||
|
||
def pytest_configure(config): | ||
"""Set the FULL_SUITE flag based on --full-suite option or environment variable.""" | ||
global FULL_SUITE | ||
FULL_SUITE = config.getoption("--full-suite") or os.getenv("FULL_TESTS") == "1" | ||
|
||
|
||
def conditional_parametrize(argnames, quick_params, full_params): | ||
"""Decorator for conditional parameterization based on FULL_SUITE flag.""" | ||
def decorator(func): | ||
if FULL_SUITE: | ||
return pytest.mark.parametrize(argnames, full_params)(func) | ||
else: | ||
return pytest.mark.parametrize(argnames, quick_params)(func) | ||
return decorator | ||
|
||
|
||
def conditional_value(quick_value, full_value): | ||
if FULL_SUITE: | ||
return quick_value | ||
return full_value |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[pytest] | ||
markers = | ||
octave: test requires Octave | ||
full: Mark tests to be included in the full suite of tests | ||
quick: Mark tests to be included in the quick suite of tests | ||
|
This file contains 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