Skip to content

Commit

Permalink
Merge pull request #692 from odlgroup/issue-679__collect_ignore
Browse files Browse the repository at this point in the history
Issue 679  collect ignore
  • Loading branch information
Holger Kohr authored Nov 1, 2016
2 parents 3f005e4 + a884587 commit 9f6785d
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ before_script:
script:
# Run tests, including PEP8 check, and produce a coverage report
- py.test --doctest-modules --cov --cov-report term-missing --pep8 $TRAVIS_BUILD_DIR/odl
# Invoke also the alternative way of running the unit tests
- python -c "import odl; odl.test()"
# Build the Sphinx doc (only for Python 3.5 and the master branch)
- if [[ "$TRAVIS_PYTHON_VERSION" == "3.5" && "$TRAVIS_BRANCH" == "master" ]]; then
cd $TRAVIS_BUILD_DIR/doc/source && python generate_doc.py && cd -;
Expand Down
1 change: 1 addition & 0 deletions odl/pytest.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[pytest]
minversion = 3.0.3
markers = not benchmark and not largescale
testpaths = odl
doctest_optionflags = NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL ELLIPSIS
Expand Down
30 changes: 17 additions & 13 deletions odl/util/pytest_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,22 @@ def add_doctest_np_odl(doctest_namespace):
doctest_namespace['odl'] = odl


# --- Files to be ignored by the tests ---
def pytest_addoption(parser):
parser.addoption('--largescale', action='store_true',
help='Run large and slow tests')

parser.addoption('--benchmark', action='store_true',
help='Run benchmarks')

parser.addoption('--examples', action='store_true',
help='Run examples')

parser.addoption('--doctest-doc', action='store_true',
help='Run doctests in the documentation')


# --- Ignored tests due to missing modules ---

this_dir = os.path.dirname(__file__)
odl_root = os.path.abspath(os.path.join(this_dir, os.pardir, os.pardir))
collect_ignore = [os.path.join(odl_root, 'setup.py')]
Expand All @@ -66,21 +79,12 @@ def add_doctest_np_odl(doctest_namespace):
os.path.join(odl_root, 'odl/trafos/wavelet.py'))


def pytest_addoption(parser):
parser.addoption('--largescale', action='store_true',
help='Run large and slow tests')

parser.addoption('--benchmark', action='store_true',
help='Run benchmarks')

parser.addoption('--examples', action='store_true',
help='Run examples')
def pytest_ignore_collect(path, config):
return str(path) in collect_ignore

parser.addoption('--doctest-doc', action='store_true',
help='Run doctests in the documentation')

# --- Reusable fixtures ---

# reusable fixtures
fn_impl_params = odl.FN_IMPLS.keys()
fn_impl_ids = [" impl='{}' ".format(p) for p in fn_impl_params]

Expand Down
7 changes: 6 additions & 1 deletion odl/util/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,12 @@ def run_doctests(skip_if=False):
optionflags = NORMALIZE_WHITESPACE
if skip_if:
optionflags |= SKIP
testmod(optionflags=optionflags)

import odl
import numpy as np

testmod(optionflags=optionflags,
extraglobs={'odl': odl, 'np': np})


if __name__ == '__main__':
Expand Down
12 changes: 12 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[pytest]
minversion = 3.0.3
markers = not benchmark and not largescale
testpaths = odl
doctest_optionflags = NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL ELLIPSIS
addopts = --doctest-modules
xfail_strict=true

# PEP8
pep8ignore =
E402
pep8maxlinelength = 79

0 comments on commit 9f6785d

Please sign in to comment.