diff --git a/.github/workflows/pip.yml b/.github/workflows/pip.yml index efbbb7f..cc47f86 100644 --- a/.github/workflows/pip.yml +++ b/.github/workflows/pip.yml @@ -52,6 +52,14 @@ jobs: run: | python -m scpdt scpdt/tests/finder_cases.py -vv + - name: Test pytest plugin + # This test will fail in a venv where scpdt has not been installed and the plugin has not been activated + run: | + test_files=("scpdt/tests/module_cases.py" "scpdt/tests/stopwords_cases.py" "scpdt/tests/local_file_cases.py") + for file in "${test_files[@]}"; do + python -m pytest "${file}" --doctest-modules + done + - name: Test testfile CLI run: | python -m scpdt ./scpdt/tests/scipy_linalg_tutorial_clone.rst -v @@ -65,10 +73,3 @@ jobs: python -mpip install pooch python -c'from scipy import ndimage; from scpdt import testmod; testmod(ndimage, verbose=True, strategy="api")' - - name: Test pytest plugin - # This test will fail in a venv where scpdt has not been installed and the plugin has not been activated - run: | - test_files=("scpdt/tests/module_cases.py" "scpdt/tests/stopwords_cases.py" "scpdt/tests/local_file_cases.py") - for file in "${test_files[@]}"; do - python -m pytest "${file}" --doctest-modules - done diff --git a/scpdt/impl.py b/scpdt/impl.py index a5923d6..26f79a1 100644 --- a/scpdt/impl.py +++ b/scpdt/impl.py @@ -68,6 +68,9 @@ class DTConfig: NameErrors. Set to True if you want to see these, or if your test is actually expected to raise NameErrors. Default is False. + pytest_extra_skips : list + A list of names/modules to skip when run under pytest plugin. Ignored + otherwise. """ def __init__(self, *, # DTChecker configuration @@ -88,6 +91,7 @@ def __init__(self, *, # DTChecker configuration # Obscure switches parse_namedtuples=True, # Checker nameerror_after_exception=False, # Runner + pytest_extra_skips=None, # plugin/collection ): ### DTChecker configuration ### # The namespace to run examples in @@ -171,6 +175,11 @@ def __init__(self, *, # DTChecker configuration self.parse_namedtuples = parse_namedtuples self.nameerror_after_exception = nameerror_after_exception + #### pytest plugin additional switches + if pytest_extra_skips is None: + pytest_extra_skips = [] + self.pytest_extra_skips = pytest_extra_skips + def try_convert_namedtuple(got): # suppose that "got" is smth like MoodResult(statistic=10, pvalue=0.1).