diff options
author | Daniel Hahler <github@thequod.de> | 2018-10-30 13:40:53 +0100 |
---|---|---|
committer | Chris Dent <chris.dent@gmail.com> | 2018-10-30 12:40:53 +0000 |
commit | 455203d2b3b0c898df6d3661cb1de577dfeda483 (patch) | |
tree | c86f8fd4df56ac146bcfdc87552dc645516c9d80 /tests | |
parent | 495ff974d1a972f3751bd6d142813f326bc3f1c1 (diff) | |
download | paste-git-455203d2b3b0c898df6d3661cb1de577dfeda483.tar.gz |
Pytest fixes (#9)
* pytest: fix collection warnings via __test__=False
Fixes
> "cannot collect test class %r because it has a __init__ constructor
Ref: https://github.com/pytest-dev/pytest/issues/2007
* pytest: configure testpaths
This is faster with test collection.
* pytest: fix warning with doctests
Fixes
> /usr/lib/python3.7/site-packages/_pytest/python.py:764:
> RemovedInPytest4Warning: usage of Generator.Function is deprecated,
> please use pytest.Function instead
* Minor fixes around s/py.test/pytest/
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_auth/test_auth_digest.py | 6 | ||||
-rw-r--r-- | tests/test_doctests.py | 26 |
2 files changed, 16 insertions, 16 deletions
diff --git a/tests/test_auth/test_auth_digest.py b/tests/test_auth/test_auth_digest.py index 1d44038..25fc3e5 100644 --- a/tests/test_auth/test_auth_digest.py +++ b/tests/test_auth/test_auth_digest.py @@ -56,10 +56,10 @@ def test_digest(): # The following code uses sockets to test the functionality, # to enable use: # -# $ TEST_SOCKET py.test -# +# $ TEST_SOCKET=1 pytest + -if os.environ.get("TEST_SOCKET",""): +if os.environ.get("TEST_SOCKET", ""): from six.moves.urllib.error import HTTPError from six.moves.urllib.request import build_opener, HTTPDigestAuthHandler from paste.debug.testserver import serve diff --git a/tests/test_doctests.py b/tests/test_doctests.py index efea589..b243ea3 100644 --- a/tests/test_doctests.py +++ b/tests/test_doctests.py @@ -1,8 +1,11 @@ -import six import doctest -from paste.util.import_string import simple_import import os +import pytest +import six + +from paste.util.import_string import simple_import + filenames = [ 'tests/template.txt', ] @@ -30,29 +33,26 @@ options = doctest.ELLIPSIS | doctest.REPORT_ONLY_FIRST_FAILURE if six.PY3: options |= doctest.IGNORE_EXCEPTION_DETAIL -def test_doctests(): - for filename in filenames: - filename = os.path.join( - os.path.dirname(os.path.dirname(__file__)), - filename) - yield do_doctest, filename -def do_doctest(filename): +@pytest.mark.parametrize('filename', filenames) +def test_doctests(filename): + filename = os.path.join( + os.path.dirname(os.path.dirname(__file__)), + filename) failure, total = doctest.testfile( filename, module_relative=False, optionflags=options) assert not failure, "Failure in %r" % filename -def test_doctest_mods(): - for module in modules: - yield do_doctest_mod, module -def do_doctest_mod(module): +@pytest.mark.parametrize('module', modules) +def test_doctest_mods(module): module = simple_import(module) failure, total = doctest.testmod( module, optionflags=options) assert not failure, "Failure in %r" % module + if __name__ == '__main__': import sys import doctest |