Skip to content

Commit

Permalink
MAINT: plumb pytest_extra_skips through to DTConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
ev-br committed Feb 20, 2024
1 parent de5e3f1 commit 6d3aaa0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/pip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
9 changes: 9 additions & 0 deletions scpdt/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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).
Expand Down

0 comments on commit 6d3aaa0

Please sign in to comment.