diff --git a/AUTHORS b/AUTHORS index e9869630b..397b896a2 100644 --- a/AUTHORS +++ b/AUTHORS @@ -23,6 +23,7 @@ Antony Lee Armin Rigo Aron Coyle Aron Curzon +Aviral Verma Aviv Palivoda Barney Gale Ben Webb diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f2d86b24f..fb00b0d0e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -114,7 +114,7 @@ Features - Captured log messages are added to the ```` tag in the generated junit xml file if the ``junit_logging`` ini option is set to ``system-out``. - If the value of this ini option is ``system-err`, the logs are written to + If the value of this ini option is ``system-err``, the logs are written to ````. The default value for ``junit_logging`` is ``no``, meaning captured logs are not written to the output file. (`#3156 `_) @@ -1206,7 +1206,7 @@ Changes * Testcase reports with a ``url`` attribute will now properly write this to junitxml. Thanks `@fushi`_ for the PR (`#1874`_). -* Remove common items from dict comparision output when verbosity=1. Also update +* Remove common items from dict comparison output when verbosity=1. Also update the truncation message to make it clearer that pytest truncates all assertion messages if verbosity < 2 (`#1512`_). Thanks `@mattduck`_ for the PR @@ -1218,7 +1218,7 @@ Changes * fix `#2013`_: turn RecordedWarning into ``namedtuple``, to give it a comprehensible repr while preventing unwarranted modification. -* fix `#2208`_: ensure a iteration limit for _pytest.compat.get_real_func. +* fix `#2208`_: ensure an iteration limit for _pytest.compat.get_real_func. Thanks `@RonnyPfannschmidt`_ for the report and PR. * Hooks are now verified after collection is complete, rather than right after loading installed plugins. This @@ -1322,7 +1322,7 @@ Bug Fixes Notably, importing the ``anydbm`` module is fixed. (`#2248`_). Thanks `@pfhayes`_ for the PR. -* junitxml: Fix problematic case where system-out tag occured twice per testcase +* junitxml: Fix problematic case where system-out tag occurred twice per testcase element in the XML report. Thanks `@kkoukiou`_ for the PR. * Fix regression, pytest now skips unittest correctly if run with ``--pdb`` @@ -2918,7 +2918,7 @@ time or change existing behaviors in order to make them less surprising/more use "::" node id specifications (copy pasted from "-v" output) - fix issue544 by only removing "@NUM" at the end of "::" separated parts - and if the part has an ".py" extension + and if the part has a ".py" extension - don't use py.std import helper, rather import things directly. Thanks Bruno Oliveira. @@ -3189,7 +3189,7 @@ time or change existing behaviors in order to make them less surprising/more use would not work correctly because pytest assumes @pytest.mark.some gets a function to be decorated already. We now at least detect if this - arg is an lambda and thus the example will work. Thanks Alex Gaynor + arg is a lambda and thus the example will work. Thanks Alex Gaynor for bringing it up. - xfail a test on pypy that checks wrong encoding/ascii (pypy does @@ -3502,7 +3502,7 @@ Bug fixes: rather use the post-2.0 parametrize features instead of yield, see: http://pytest.org/latest/example/parametrize.html - fix autouse-issue where autouse-fixtures would not be discovered - if defined in a a/conftest.py file and tests in a/tests/test_some.py + if defined in an a/conftest.py file and tests in a/tests/test_some.py - fix issue226 - LIFO ordering for fixture teardowns - fix issue224 - invocations with >256 char arguments now work - fix issue91 - add/discuss package/directory level setups in example @@ -4072,7 +4072,7 @@ Bug fixes: - make path.bestrelpath(path) return ".", note that when calling X.bestrelpath the assumption is that X is a directory. - make initial conftest discovery ignore "--" prefixed arguments -- fix resultlog plugin when used in an multicpu/multihost xdist situation +- fix resultlog plugin when used in a multicpu/multihost xdist situation (thanks Jakub Gustak) - perform distributed testing related reporting in the xdist-plugin rather than having dist-related code in the generic py.test diff --git a/README.rst b/README.rst index b2ed1e140..dd8838d16 100644 --- a/README.rst +++ b/README.rst @@ -6,13 +6,13 @@ ------ .. image:: https://img.shields.io/pypi/v/pytest.svg - :target: https://pypi.python.org/pypi/pytest + :target: https://pypi.org/project/pytest/ -.. image:: https://anaconda.org/conda-forge/pytest/badges/version.svg +.. image:: https://img.shields.io/conda/vn/conda-forge/pytest.svg :target: https://anaconda.org/conda-forge/pytest .. image:: https://img.shields.io/pypi/pyversions/pytest.svg - :target: https://pypi.python.org/pypi/pytest + :target: https://pypi.org/project/pytest/ .. image:: https://img.shields.io/coveralls/pytest-dev/pytest/master.svg :target: https://coveralls.io/r/pytest-dev/pytest diff --git a/_pytest/_code/source.py b/_pytest/_code/source.py index cb5e13f05..6c2856ea8 100644 --- a/_pytest/_code/source.py +++ b/_pytest/_code/source.py @@ -14,7 +14,7 @@ cpy_compile = compile class Source(object): - """ a immutable object holding a source code fragment, + """ an immutable object holding a source code fragment, possibly deindenting it. """ _compilecounter = 0 diff --git a/_pytest/assertion/util.py b/_pytest/assertion/util.py index 06d60a6fc..7848d0997 100644 --- a/_pytest/assertion/util.py +++ b/_pytest/assertion/util.py @@ -171,10 +171,22 @@ def _diff_text(left, right, verbose=False): """ from difflib import ndiff explanation = [] + + def escape_for_readable_diff(binary_text): + """ + Ensures that the internal string is always valid unicode, converting any bytes safely to valid unicode. + This is done using repr() which then needs post-processing to fix the encompassing quotes and un-escape + newlines and carriage returns (#429). + """ + r = six.text_type(repr(binary_text)[1:-1]) + r = r.replace(r'\n', '\n') + r = r.replace(r'\r', '\r') + return r + if isinstance(left, six.binary_type): - left = u(repr(left)[1:-1]).replace(r'\n', '\n') + left = escape_for_readable_diff(left) if isinstance(right, six.binary_type): - right = u(repr(right)[1:-1]).replace(r'\n', '\n') + right = escape_for_readable_diff(right) if not verbose: i = 0 # just in case left or right has zero length for i in range(min(len(left), len(right))): @@ -197,6 +209,10 @@ def _diff_text(left, right, verbose=False): left = left[:-i] right = right[:-i] keepends = True + if left.isspace() or right.isspace(): + left = repr(str(left)) + right = repr(str(right)) + explanation += [u'Strings contain only whitespace, escaping them using repr()'] explanation += [line.strip('\n') for line in ndiff(left.splitlines(keepends), right.splitlines(keepends))] diff --git a/_pytest/capture.py b/_pytest/capture.py index 9f4f41c41..d71f59ac2 100644 --- a/_pytest/capture.py +++ b/_pytest/capture.py @@ -315,7 +315,7 @@ class CaptureFixture(object): def safe_text_dupfile(f, mode, default_encoding="UTF8"): - """ return a open text file object that's a duplicate of f on the + """ return an open text file object that's a duplicate of f on the FD-level if possible. """ encoding = getattr(f, "encoding", None) diff --git a/_pytest/compat.py b/_pytest/compat.py index a5fa03719..e5c8c3940 100644 --- a/_pytest/compat.py +++ b/_pytest/compat.py @@ -257,7 +257,7 @@ def safe_getattr(object, name, default): def _is_unittest_unexpected_success_a_failure(): - """Return if the test suite should fail if a @expectedFailure unittest test PASSES. + """Return if the test suite should fail if an @expectedFailure unittest test PASSES. From https://docs.python.org/3/library/unittest.html?highlight=unittest#unittest.TestResult.wasSuccessful: Changed in version 3.4: Returns False if there were any diff --git a/_pytest/doctest.py b/_pytest/doctest.py index 131109cba..4511f5889 100644 --- a/_pytest/doctest.py +++ b/_pytest/doctest.py @@ -24,7 +24,7 @@ DOCTEST_REPORT_CHOICES = ( DOCTEST_REPORT_CHOICE_ONLY_FIRST_FAILURE, ) -# Lazy definiton of runner class +# Lazy definition of runner class RUNNER_CLASS = None diff --git a/_pytest/fixtures.py b/_pytest/fixtures.py index fa16fea64..ab524cc71 100644 --- a/_pytest/fixtures.py +++ b/_pytest/fixtures.py @@ -291,7 +291,7 @@ class FixtureRequest(FuncargnamesCompatAttr): def _getnextfixturedef(self, argname): fixturedefs = self._arg2fixturedefs.get(argname, None) if fixturedefs is None: - # we arrive here because of a a dynamic call to + # we arrive here because of a dynamic call to # getfixturevalue(argname) usage which was naturally # not known at parsing/collection time parentid = self._pyfuncitem.parent.nodeid @@ -1028,7 +1028,7 @@ class FixtureManager(object): def getfixtureclosure(self, fixturenames, parentnode): # collect the closure of all fixtures , starting with the given # fixturenames as the initial set. As we have to visit all - # factory definitions anyway, we also return a arg2fixturedefs + # factory definitions anyway, we also return an arg2fixturedefs # mapping so that the caller can reuse it and does not have # to re-discover fixturedefs again for each fixturename # (discovering matching fixtures for a given name/node is expensive) diff --git a/_pytest/freeze_support.py b/_pytest/freeze_support.py index 97147a882..52b84eb49 100644 --- a/_pytest/freeze_support.py +++ b/_pytest/freeze_support.py @@ -7,7 +7,7 @@ from __future__ import absolute_import, division, print_function def freeze_includes(): """ - Returns a list of module names used by py.test that should be + Returns a list of module names used by pytest that should be included by cx_freeze. """ import py diff --git a/_pytest/main.py b/_pytest/main.py index 03db67b60..6c4bd65bb 100644 --- a/_pytest/main.py +++ b/_pytest/main.py @@ -90,7 +90,7 @@ def pytest_addoption(parser): def pytest_configure(config): - __import__('pytest').config = config # compatibiltiy + __import__('pytest').config = config # compatibility def wrap_session(config, doit): @@ -290,7 +290,7 @@ class Interrupted(KeyboardInterrupt): class Failed(Exception): - """ signals an stop as failed test run. """ + """ signals a stop as failed test run. """ class Session(nodes.FSCollector): diff --git a/_pytest/mark/structures.py b/_pytest/mark/structures.py index 5b33f3abb..72fd264b2 100644 --- a/_pytest/mark/structures.py +++ b/_pytest/mark/structures.py @@ -215,7 +215,7 @@ class MarkDecorator(object): def get_unpacked_marks(obj): """ - obtain the unpacked marks that are stored on a object + obtain the unpacked marks that are stored on an object """ mark_list = getattr(obj, 'pytestmark', []) @@ -228,7 +228,7 @@ def get_unpacked_marks(obj): def store_mark(obj, mark): - """store a Mark on a object + """store a Mark on an object this is used to implement the Mark declarations/decorators correctly """ assert isinstance(mark, Mark), mark diff --git a/_pytest/outcomes.py b/_pytest/outcomes.py index 7f0c18fa6..640c5773a 100644 --- a/_pytest/outcomes.py +++ b/_pytest/outcomes.py @@ -83,7 +83,7 @@ skip.Exception = Skipped def fail(msg="", pytrace=True): - """ explicitly fail an currently-executing test with the given Message. + """ explicitly fail a currently-executing test with the given Message. :arg pytrace: if false the msg represents the full failure information and no python traceback will be reported. diff --git a/_pytest/pytester.py b/_pytest/pytester.py index c14a34d7e..27dd8289d 100644 --- a/_pytest/pytester.py +++ b/_pytest/pytester.py @@ -714,7 +714,7 @@ class Testdir(object): """ finalizers = [] try: - # When running py.test inline any plugins active in the main test + # When running pytest inline any plugins active in the main test # process are already imported. So this disables the warning which # will trigger to say they can no longer be rewritten, which is # fine as they have already been rewritten. @@ -725,7 +725,7 @@ class Testdir(object): finalizers.append(revert_warn_already_imported) AssertionRewritingHook._warn_already_imported = lambda *a: None - # Any sys.module or sys.path changes done while running py.test + # Any sys.module or sys.path changes done while running pytest # inline should be reverted after the test run completes to avoid # clashing with later inline tests run within the same pytest test, # e.g. just because they use matching test module names. diff --git a/_pytest/python.py b/_pytest/python.py index 5bb439480..821f844eb 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -55,7 +55,7 @@ def filter_traceback(entry): is_generated = '<' in raw_filename and '>' in raw_filename if is_generated: return False - # entry.path might point to an non-existing file, in which case it will + # entry.path might point to a non-existing file, in which case it will # also return a str object. see #1133 p = py.path.local(entry.path) return not p.relto(_pluggy_dir) and not p.relto(_pytest_dir) and not p.relto(_py_dir) diff --git a/changelog/3303.doc.rst b/changelog/3303.doc.rst new file mode 100644 index 000000000..0af91ffb0 --- /dev/null +++ b/changelog/3303.doc.rst @@ -0,0 +1 @@ +Change documentation copyright year to a range which auto-updates itself each time it is published. diff --git a/changelog/3431.trivial.rst b/changelog/3431.trivial.rst new file mode 100644 index 000000000..08bc64e8e --- /dev/null +++ b/changelog/3431.trivial.rst @@ -0,0 +1 @@ +Update all pypi.python.org URLs to pypi.org. diff --git a/changelog/3443.bugfix.rst b/changelog/3443.bugfix.rst new file mode 100644 index 000000000..e8bdcdf1d --- /dev/null +++ b/changelog/3443.bugfix.rst @@ -0,0 +1 @@ +When showing diffs of failed assertions where the contents contain only whitespace, escape them using ``repr()`` first to make it easy to spot the differences. diff --git a/doc/en/_templates/links.html b/doc/en/_templates/links.html index 91157dfb7..3a1a27a26 100644 --- a/doc/en/_templates/links.html +++ b/doc/en/_templates/links.html @@ -1,6 +1,6 @@

Useful Links

    -
  • pytest @ PyPI
  • +
  • pytest @ PyPI
  • pytest @ GitHub
  • 3rd party plugins
  • Issue Tracker
  • diff --git a/doc/en/announce/release-2.3.4.rst b/doc/en/announce/release-2.3.4.rst index d6c597b54..fc5f361d5 100644 --- a/doc/en/announce/release-2.3.4.rst +++ b/doc/en/announce/release-2.3.4.rst @@ -18,7 +18,7 @@ comes with the following fixes and features: rather use the post-2.0 parametrize features instead of yield, see: http://pytest.org/latest/example/parametrize.html - fix autouse-issue where autouse-fixtures would not be discovered - if defined in a a/conftest.py file and tests in a/tests/test_some.py + if defined in an a/conftest.py file and tests in a/tests/test_some.py - fix issue226 - LIFO ordering for fixture teardowns - fix issue224 - invocations with >256 char arguments now work - fix issue91 - add/discuss package/directory level setups in example diff --git a/doc/en/announce/release-2.3.5.rst b/doc/en/announce/release-2.3.5.rst index 112399ef3..bb4e84af0 100644 --- a/doc/en/announce/release-2.3.5.rst +++ b/doc/en/announce/release-2.3.5.rst @@ -14,7 +14,7 @@ few interesting new plugins saw the light last month: And several others like pytest-django saw maintenance releases. For a more complete list, check out -https://pypi.python.org/pypi?%3Aaction=search&term=pytest&submit=search. +https://pypi.org/search/?q=pytest For general information see: diff --git a/doc/en/announce/release-2.4.0.rst b/doc/en/announce/release-2.4.0.rst index be3aaedb0..4fb3d05cd 100644 --- a/doc/en/announce/release-2.4.0.rst +++ b/doc/en/announce/release-2.4.0.rst @@ -23,14 +23,14 @@ a full list of details. A few feature highlights: called if the corresponding setup method succeeded. - integrate tab-completion on command line options if you - have `argcomplete `_ + have `argcomplete `_ configured. - allow boolean expression directly with skipif/xfail if a "reason" is also specified. - a new hook ``pytest_load_initial_conftests`` allows plugins like - `pytest-django `_ to + `pytest-django `_ to influence the environment before conftest files import ``django``. - reporting: color the last line red or green depending if diff --git a/doc/en/announce/release-2.6.1.rst b/doc/en/announce/release-2.6.1.rst index 6f27c5861..2f3257cd8 100644 --- a/doc/en/announce/release-2.6.1.rst +++ b/doc/en/announce/release-2.6.1.rst @@ -52,7 +52,7 @@ Changes 2.6.1 "::" node id specifications (copy pasted from "-v" output) - fix issue544 by only removing "@NUM" at the end of "::" separated parts - and if the part has an ".py" extension + and if the part has a ".py" extension - don't use py.std import helper, rather import things directly. Thanks Bruno Oliveira. diff --git a/doc/en/cache.rst b/doc/en/cache.rst index 10543ef3b..57a091116 100644 --- a/doc/en/cache.rst +++ b/doc/en/cache.rst @@ -234,7 +234,7 @@ Inspecting Cache content You can always peek at the content of the cache using the ``--cache-show`` command line option:: - $ py.test --cache-show + $ pytest --cache-show =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y rootdir: $REGENDOC_TMPDIR, inifile: diff --git a/doc/en/conf.py b/doc/en/conf.py index f5c17404b..d64b81117 100644 --- a/doc/en/conf.py +++ b/doc/en/conf.py @@ -20,6 +20,7 @@ import os import sys +import datetime from _pytest import __version__ as version @@ -57,7 +58,8 @@ master_doc = 'contents' # General information about the project. project = u'pytest' -copyright = u'2015, holger krekel and pytest-dev team' +year = datetime.datetime.utcnow().year +copyright = u'2015–{} , holger krekel and pytest-dev team'.format(year) diff --git a/doc/en/development_guide.rst b/doc/en/development_guide.rst index 2dac82880..f69371a5a 100644 --- a/doc/en/development_guide.rst +++ b/doc/en/development_guide.rst @@ -10,7 +10,7 @@ Code Style ---------- * `PEP-8 `_ -* `flake8 `_ for quality checks +* `flake8 `_ for quality checks * `invoke `_ to automate development tasks diff --git a/doc/en/example/nonpython.rst b/doc/en/example/nonpython.rst index dd25e888f..ca7b2c8df 100644 --- a/doc/en/example/nonpython.rst +++ b/doc/en/example/nonpython.rst @@ -10,7 +10,7 @@ A basic example for specifying tests in Yaml files -------------------------------------------------------------- .. _`pytest-yamlwsgi`: http://bitbucket.org/aafshar/pytest-yamlwsgi/src/tip/pytest_yamlwsgi.py -.. _`PyYAML`: http://pypi.python.org/pypi/PyYAML/ +.. _`PyYAML`: https://pypi.org/project/PyYAML/ Here is an example ``conftest.py`` (extracted from Ali Afshnars special purpose `pytest-yamlwsgi`_ plugin). This ``conftest.py`` will collect ``test*.yml`` files and will execute the yaml-formatted content as custom tests: diff --git a/doc/en/example/parametrize.rst b/doc/en/example/parametrize.rst index dd01b2527..2cf3fa1e4 100644 --- a/doc/en/example/parametrize.rst +++ b/doc/en/example/parametrize.rst @@ -160,7 +160,7 @@ together with the actual data, instead of listing them separately. A quick port of "testscenarios" ------------------------------------ -.. _`test scenarios`: http://pypi.python.org/pypi/testscenarios/ +.. _`test scenarios`: https://pypi.org/project/testscenarios/ Here is a quick port to run tests configured with `test scenarios`_, an add-on from Robert Collins for the standard unittest framework. We @@ -469,7 +469,7 @@ If you run this with reporting for skips enabled:: =================== 1 passed, 1 skipped in 0.12 seconds ==================== -You'll see that we don't have a ``opt2`` module and thus the second test run +You'll see that we don't have an ``opt2`` module and thus the second test run of our ``test_func1`` was skipped. A few notes: - the fixture functions in the ``conftest.py`` file are "session-scoped" because we diff --git a/doc/en/example/pythoncollection.rst b/doc/en/example/pythoncollection.rst index fc8dbf1b5..58b4364b5 100644 --- a/doc/en/example/pythoncollection.rst +++ b/doc/en/example/pythoncollection.rst @@ -54,7 +54,7 @@ Keeping duplicate paths specified from command line Default behavior of ``pytest`` is to ignore duplicate paths specified from the command line. Example:: - py.test path_a path_a + pytest path_a path_a ... collected 1 item @@ -65,7 +65,7 @@ Just collect tests once. To collect duplicate tests, use the ``--keep-duplicates`` option on the cli. Example:: - py.test --keep-duplicates path_a path_a + pytest --keep-duplicates path_a path_a ... collected 2 items @@ -75,7 +75,7 @@ As the collector just works on directories, if you specify twice a single test f still collect it twice, no matter if the ``--keep-duplicates`` is not specified. Example:: - py.test test_a.py test_a.py + pytest test_a.py test_a.py ... collected 2 items diff --git a/doc/en/example/simple.rst b/doc/en/example/simple.rst index ce9ec8603..634e01d5d 100644 --- a/doc/en/example/simple.rst +++ b/doc/en/example/simple.rst @@ -108,7 +108,7 @@ the command line arguments before they get processed: num = max(multiprocessing.cpu_count() / 2, 1) args[:] = ["-n", str(num)] + args -If you have the `xdist plugin `_ installed +If you have the `xdist plugin `_ installed you will now always perform test runs using a number of subprocesses close to your CPU. Running in an empty directory with the above conftest.py:: @@ -778,7 +778,7 @@ which test got stuck, for example if pytest was run in quiet mode (``-q``) or yo output. This is particularly a problem if the problem helps only sporadically, the famous "flaky" kind of tests. ``pytest`` sets a ``PYTEST_CURRENT_TEST`` environment variable when running tests, which can be inspected -by process monitoring utilities or libraries like `psutil `_ to discover which +by process monitoring utilities or libraries like `psutil `_ to discover which test got stuck if necessary: .. code-block:: python diff --git a/doc/en/faq.rst b/doc/en/faq.rst index 27d74e114..5b13818ea 100644 --- a/doc/en/faq.rst +++ b/doc/en/faq.rst @@ -30,14 +30,14 @@ and does not handle Deferreds returned from a test in pytest style. If you are using trial's unittest.TestCase chances are that you can just run your tests even if you return Deferreds. In addition, there also is a dedicated `pytest-twisted -`_ plugin which allows you to +`_ plugin which allows you to return deferreds from pytest-style tests, allowing the use of :ref:`fixtures` and other features. how does pytest work with Django? ++++++++++++++++++++++++++++++++++++++++++++++ -In 2012, some work is going into the `pytest-django plugin `_. It substitutes the usage of Django's +In 2012, some work is going into the `pytest-django plugin `_. It substitutes the usage of Django's ``manage.py test`` and allows the use of all pytest features_ most of which are not available from Django directly. diff --git a/doc/en/fixture.rst b/doc/en/fixture.rst index fbb922d79..f1cdf622a 100644 --- a/doc/en/fixture.rst +++ b/doc/en/fixture.rst @@ -154,7 +154,7 @@ This makes use of the automatic caching mechanisms of pytest. Another good approach is by adding the data files in the ``tests`` folder. There are also community plugins available to help managing this aspect of testing, e.g. `pytest-datadir `__ -and `pytest-datafiles `__. +and `pytest-datafiles `__. .. _smtpshared: diff --git a/doc/en/getting-started.rst b/doc/en/getting-started.rst index 7b9bfba57..aae0bf971 100644 --- a/doc/en/getting-started.rst +++ b/doc/en/getting-started.rst @@ -5,10 +5,10 @@ Installation and Getting Started **Platforms**: Unix/Posix and Windows -**PyPI package name**: `pytest `_ +**PyPI package name**: `pytest `_ -**Dependencies**: `py `_, -`colorama (Windows) `_, +**Dependencies**: `py `_, +`colorama (Windows) `_, **Documentation as PDF**: `download latest `_ diff --git a/doc/en/goodpractices.rst b/doc/en/goodpractices.rst index 16fdd24c3..d9f0fff11 100644 --- a/doc/en/goodpractices.rst +++ b/doc/en/goodpractices.rst @@ -145,7 +145,7 @@ Note that this layout also works in conjunction with the ``src`` layout mentione .. note:: - If ``pytest`` finds a "a/b/test_module.py" test file while + If ``pytest`` finds an "a/b/test_module.py" test file while recursing into the filesystem it determines the import name as follows: @@ -168,9 +168,9 @@ Note that this layout also works in conjunction with the ``src`` layout mentione to avoid surprises such as a test module getting imported twice. -.. _`virtualenv`: http://pypi.python.org/pypi/virtualenv +.. _`virtualenv`: https://pypi.org/project/virtualenv/ .. _`buildout`: http://www.buildout.org/ -.. _pip: http://pypi.python.org/pypi/pip +.. _pip: https://pypi.org/project/pip/ .. _`use tox`: @@ -205,7 +205,7 @@ Integrating with setuptools / ``python setup.py test`` / ``pytest-runner`` -------------------------------------------------------------------------- You can integrate test runs into your setuptools based project -with the `pytest-runner `_ plugin. +with the `pytest-runner `_ plugin. Add this to ``setup.py`` file: diff --git a/doc/en/links.inc b/doc/en/links.inc index b69390baa..4d5a4b1ee 100644 --- a/doc/en/links.inc +++ b/doc/en/links.inc @@ -7,14 +7,14 @@ .. _`reStructured Text`: http://docutils.sourceforge.net .. _`Python debugger`: http://docs.python.org/lib/module-pdb.html .. _nose: https://nose.readthedocs.io/en/latest/ -.. _pytest: http://pypi.python.org/pypi/pytest +.. _pytest: https://pypi.org/project/pytest/ .. _mercurial: http://mercurial.selenic.com/wiki/ -.. _`setuptools`: http://pypi.python.org/pypi/setuptools +.. _`setuptools`: https://pypi.org/project/setuptools/ .. _`easy_install`: .. _`distribute docs`: -.. _`distribute`: http://pypi.python.org/pypi/distribute -.. _`pip`: http://pypi.python.org/pypi/pip -.. _`virtualenv`: http://pypi.python.org/pypi/virtualenv +.. _`distribute`: https://pypi.org/project/distribute/ +.. _`pip`: https://pypi.org/project/pip/ +.. _`virtualenv`: https://pypi.org/project/virtualenv/ .. _hudson: http://hudson-ci.org/ .. _jenkins: http://jenkins-ci.org/ .. _tox: http://testrun.org/tox diff --git a/doc/en/plugins.rst b/doc/en/plugins.rst index 3d1226d34..9ddba5d38 100644 --- a/doc/en/plugins.rst +++ b/doc/en/plugins.rst @@ -20,39 +20,39 @@ Here is a little annotated list for some popular plugins: .. _`django`: https://www.djangoproject.com/ -* `pytest-django `_: write tests +* `pytest-django `_: write tests for `django`_ apps, using pytest integration. -* `pytest-twisted `_: write tests +* `pytest-twisted `_: write tests for `twisted `_ apps, starting a reactor and processing deferreds from test functions. -* `pytest-cov `_: +* `pytest-cov `_: coverage reporting, compatible with distributed testing -* `pytest-xdist `_: +* `pytest-xdist `_: to distribute tests to CPUs and remote hosts, to run in boxed mode which allows to survive segmentation faults, to run in looponfailing mode, automatically re-running failing tests on file changes. -* `pytest-instafail `_: +* `pytest-instafail `_: to report failures while the test run is happening. -* `pytest-bdd `_ and - `pytest-konira `_ +* `pytest-bdd `_ and + `pytest-konira `_ to write tests using behaviour-driven testing. -* `pytest-timeout `_: +* `pytest-timeout `_: to timeout tests based on function marks or global definitions. -* `pytest-pep8 `_: +* `pytest-pep8 `_: a ``--pep8`` option to enable PEP8 compliance checking. -* `pytest-flakes `_: +* `pytest-flakes `_: check source code with pyflakes. -* `oejskit `_: +* `oejskit `_: a plugin to run javascript unittests in live browsers. To see a complete list of all plugins with their latest testing @@ -61,7 +61,7 @@ status against different pytest and Python versions, please visit You may also discover more plugins through a `pytest- pypi.python.org search`_. -.. _`pytest- pypi.python.org search`: http://pypi.python.org/pypi?%3Aaction=search&term=pytest-&submit=search +.. _`pytest- pypi.python.org search`: https://pypi.org/search/?q=pytest- .. _`available installable plugins`: diff --git a/doc/en/projects.rst b/doc/en/projects.rst index 51f2d94fd..606e9d47c 100644 --- a/doc/en/projects.rst +++ b/doc/en/projects.rst @@ -32,40 +32,40 @@ Here are some examples of projects using ``pytest`` (please send notes via :ref: * `PyPM `_ ActiveState's package manager * `Fom `_ a fluid object mapper for FluidDB * `applib `_ cross-platform utilities -* `six `_ Python 2 and 3 compatibility utilities +* `six `_ Python 2 and 3 compatibility utilities * `pediapress `_ MediaWiki articles -* `mwlib `_ mediawiki parser and utility library +* `mwlib `_ mediawiki parser and utility library * `The Translate Toolkit `_ for localization and conversion * `execnet `_ rapid multi-Python deployment * `pylib `_ cross-platform path, IO, dynamic code library * `Pacha `_ configuration management in five minutes -* `bbfreeze `_ create standalone executables from Python scripts +* `bbfreeze `_ create standalone executables from Python scripts * `pdb++ `_ a fancier version of PDB * `py-s3fuse `_ Amazon S3 FUSE based filesystem * `waskr `_ WSGI Stats Middleware * `guachi `_ global persistent configs for Python modules -* `Circuits `_ lightweight Event Driven Framework +* `Circuits `_ lightweight Event Driven Framework * `pygtk-helpers `_ easy interaction with PyGTK * `QuantumCore `_ statusmessage and repoze openid plugin * `pydataportability `_ libraries for managing the open web * `XIST `_ extensible HTML/XML generator -* `tiddlyweb `_ optionally headless, extensible RESTful datastore +* `tiddlyweb `_ optionally headless, extensible RESTful datastore * `fancycompleter `_ for colorful tab-completion * `Paludis `_ tools for Gentoo Paludis package manager * `Gerald `_ schema comparison tool * `abjad `_ Python API for Formalized Score control * `bu `_ a microscopic build system * `katcp `_ Telescope communication protocol over Twisted -* `kss plugin timer `_ +* `kss plugin timer `_ * `pyudev `_ a pure Python binding to the Linux library libudev * `pytest-localserver `_ a plugin for pytest that provides an httpserver and smtpserver -* `pytest-monkeyplus `_ a plugin that extends monkeypatch +* `pytest-monkeyplus `_ a plugin that extends monkeypatch These projects help integrate ``pytest`` into other Python frameworks: -* `pytest-django `_ for Django +* `pytest-django `_ for Django * `zope.pytest `_ for Zope and Grok -* `pytest_gae `_ for Google App Engine +* `pytest_gae `_ for Google App Engine * There is `some work `_ underway for Kotti, a CMS built in Pyramid/Pylons diff --git a/doc/en/proposals/parametrize_with_fixtures.rst b/doc/en/proposals/parametrize_with_fixtures.rst index 146032aa4..eb4b07879 100644 --- a/doc/en/proposals/parametrize_with_fixtures.rst +++ b/doc/en/proposals/parametrize_with_fixtures.rst @@ -118,7 +118,7 @@ all parameters marked as a fixture. .. note:: - The `pytest-lazy-fixture `_ plugin implements a very + The `pytest-lazy-fixture `_ plugin implements a very similar solution to the proposal below, make sure to check it out. .. code-block:: python diff --git a/doc/en/reference.rst b/doc/en/reference.rst index be2180c53..28a375139 100644 --- a/doc/en/reference.rst +++ b/doc/en/reference.rst @@ -150,7 +150,7 @@ Unconditionally skip a test function. pytest.mark.skipif ~~~~~~~~~~~~~~~~~~ -**Tutorial**: :ref:`xfail`. +**Tutorial**: :ref:`skipif`. Skip a test function if a condition is ``True``. @@ -945,8 +945,8 @@ passed multiple times. The expected format is ``name=value``. For example:: Allows to pick the action for empty parametersets in parameterization - * ``skip`` skips tests with a empty parameterset (default) - * ``xfail`` marks tests with a empty parameterset as xfail(run=False) + * ``skip`` skips tests with an empty parameterset (default) + * ``xfail`` marks tests with an empty parameterset as xfail(run=False) .. code-block:: ini diff --git a/doc/en/test/plugin/cov.rst b/doc/en/test/plugin/cov.rst index 541c7ef94..0b95aa452 100644 --- a/doc/en/test/plugin/cov.rst +++ b/doc/en/test/plugin/cov.rst @@ -21,7 +21,7 @@ The `pytest-cov`_ package may be installed with pip or easy_install:: pip install pytest-cov easy_install pytest-cov -.. _`pytest-cov`: http://pypi.python.org/pypi/pytest-cov/ +.. _`pytest-cov`: https://pypi.org/project/pytest-cov/ Uninstallation diff --git a/doc/en/test/plugin/oejskit.rst b/doc/en/test/plugin/oejskit.rst index 4995aa17c..791f5c725 100644 --- a/doc/en/test/plugin/oejskit.rst +++ b/doc/en/test/plugin/oejskit.rst @@ -7,6 +7,6 @@ The approach enables to write integration tests such that the JavaScript code is For more info and download please visit the `oejskit PyPI`_ page. .. _`oejskit`: -.. _`oejskit PyPI`: http://pypi.python.org/pypi/oejskit +.. _`oejskit PyPI`: https://pypi.org/project/oejskit/ .. source link 'http://bitbucket.org/pedronis/js-infrastructure/src/tip/pytest_jstests.py', diff --git a/doc/en/test/plugin/xdist.rst b/doc/en/test/plugin/xdist.rst index 506d240ae..865b3596d 100644 --- a/doc/en/test/plugin/xdist.rst +++ b/doc/en/test/plugin/xdist.rst @@ -26,7 +26,7 @@ program source code to the remote place. All test results are reported back and displayed to your local test session. You may specify different Python versions and interpreters. -.. _`pytest-xdist`: http://pypi.python.org/pypi/pytest-xdist +.. _`pytest-xdist`: https://pypi.org/project/pytest-xdist/ Usage examples --------------------- diff --git a/doc/en/unittest.rst b/doc/en/unittest.rst index b44bda44f..1bc33ab19 100644 --- a/doc/en/unittest.rst +++ b/doc/en/unittest.rst @@ -46,9 +46,9 @@ in most cases without having to modify existing code: * :ref:`maxfail`; * :ref:`--pdb ` command-line option for debugging on test failures (see :ref:`note ` below); -* Distribute tests to multiple CPUs using the `pytest-xdist `_ plugin; +* Distribute tests to multiple CPUs using the `pytest-xdist `_ plugin; * Use :ref:`plain assert-statements ` instead of ``self.assert*`` functions (`unittest2pytest - `__ is immensely helpful in this); + `__ is immensely helpful in this); pytest features in ``unittest.TestCase`` subclasses diff --git a/doc/en/usage.rst b/doc/en/usage.rst index 72b2eedc9..b9b8059f7 100644 --- a/doc/en/usage.rst +++ b/doc/en/usage.rst @@ -421,7 +421,7 @@ Creating resultlog format files This option is rarely used and is scheduled for removal in 4.0. An alternative for users which still need similar functionality is to use the - `pytest-tap `_ plugin which provides + `pytest-tap `_ plugin which provides a stream of test data. If you have any concerns, please don't hesitate to diff --git a/doc/en/writing_plugins.rst b/doc/en/writing_plugins.rst index 7da09dbbb..67c885efb 100644 --- a/doc/en/writing_plugins.rst +++ b/doc/en/writing_plugins.rst @@ -103,7 +103,7 @@ Here is how you might run it:: Writing your own plugin ----------------------- -.. _`setuptools`: http://pypi.python.org/pypi/setuptools +.. _`setuptools`: https://pypi.org/project/setuptools/ If you want to write a plugin, there are many real-life examples you can copy from: diff --git a/testing/code/test_excinfo.py b/testing/code/test_excinfo.py index 6b4adf001..8fd59423f 100644 --- a/testing/code/test_excinfo.py +++ b/testing/code/test_excinfo.py @@ -1198,7 +1198,7 @@ def test_cwd_deleted(testdir): def test_exception_repr_extraction_error_on_recursion(): """ Ensure we can properly detect a recursion error even - if some locals raise error on comparision (#2459). + if some locals raise error on comparison (#2459). """ class numpy_like(object): diff --git a/testing/python/fixture.py b/testing/python/fixture.py index 2ba890d05..d9f08a3f0 100644 --- a/testing/python/fixture.py +++ b/testing/python/fixture.py @@ -523,6 +523,7 @@ class TestRequestBasic(object): testdir.makepyfile(""" import sys import pytest + from _pytest.compat import safe_str import gc @pytest.fixture(autouse=True) @@ -539,7 +540,7 @@ class TestRequestBasic(object): gc.collect() leaked_types = sum(1 for _ in gc.garbage - if 'PseudoFixtureDef' in str(_)) + if 'PseudoFixtureDef' in safe_str(_)) gc.garbage[:] = [] @@ -1552,7 +1553,7 @@ class TestAutouseDiscovery(object): def test_callables_nocode(self, testdir): """ - a imported mock.call would break setup/factory discovery + an imported mock.call would break setup/factory discovery due to it being callable and __code__ not being a code object """ testdir.makepyfile(""" diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py index b96851627..db6dae318 100644 --- a/testing/python/metafunc.py +++ b/testing/python/metafunc.py @@ -194,6 +194,7 @@ class TestMetafunc(object): assert metafunc._calls[3].id == "x1-b" @hypothesis.given(strategies.text() | strategies.binary()) + @hypothesis.settings(deadline=400.0) # very close to std deadline and CI boxes are not reliable in CPU power def test_idval_hypothesis(self, value): from _pytest.python import _idval escaped = _idval(value, 'a', 6, None) diff --git a/testing/test_assertion.py b/testing/test_assertion.py index 328fe7fa9..51229d3e1 100644 --- a/testing/test_assertion.py +++ b/testing/test_assertion.py @@ -473,7 +473,7 @@ class TestAssert_reprcompare(object): def test_one_repr_empty(self): """ the faulty empty string repr did trigger - a unbound local error in _diff_text + an unbound local error in _diff_text """ class A(str): def __repr__(self): @@ -746,6 +746,18 @@ def test_reprcompare_notin(mock_config): assert detail == ["'foo' is contained here:", ' aaafoobbb', '? +++'] +def test_reprcompare_whitespaces(mock_config): + detail = plugin.pytest_assertrepr_compare( + mock_config, '==', '\r\n', '\n') + assert detail == [ + r"'\r\n' == '\n'", + r"Strings contain only whitespace, escaping them using repr()", + r"- '\r\n'", + r"? --", + r"+ '\n'", + ] + + def test_pytest_assertrepr_compare_integration(testdir): testdir.makepyfile(""" def test_hello(): diff --git a/testing/test_capture.py b/testing/test_capture.py index 7fccc055d..bc8ae6534 100644 --- a/testing/test_capture.py +++ b/testing/test_capture.py @@ -998,7 +998,7 @@ class TestStdCapture(object): reason='text output different for bytes on python3') def test_capturing_readouterr_decode_error_handling(self): with self.getcapture() as cap: - # triggered a internal error in pytest + # triggered an internal error in pytest print('\xa6') out, err = cap.readouterr() assert out == py.builtin._totext('\ufffd\n', 'unicode-escape') diff --git a/testing/test_conftest.py b/testing/test_conftest.py index 6566f752a..93bf8ea8d 100644 --- a/testing/test_conftest.py +++ b/testing/test_conftest.py @@ -373,7 +373,7 @@ class TestConftestVisibility(object): (None, 1, 1), ]) def test_search_conftest_up_to_inifile(testdir, confcutdir, passed, error): - """Test that conftest files are detected only up to a ini file, unless + """Test that conftest files are detected only up to an ini file, unless an explicit --confcutdir option is given. """ root = testdir.tmpdir diff --git a/testing/test_nose.py b/testing/test_nose.py index df3e1a94b..1964b06c5 100644 --- a/testing/test_nose.py +++ b/testing/test_nose.py @@ -289,7 +289,7 @@ def test_nose_setup_ordering(testdir): def test_apiwrapper_problem_issue260(testdir): - # this would end up trying a call a optional teardown on the class + # this would end up trying a call an optional teardown on the class # for plain unittests we dont want nose behaviour testdir.makepyfile(""" import unittest diff --git a/tox.ini b/tox.ini index f4f5c3bf2..981945265 100644 --- a/tox.ini +++ b/tox.ini @@ -20,7 +20,7 @@ envlist = commands = pytest --lsof -ra {posargs:testing} passenv = USER USERNAME deps = - hypothesis>=3.5.2 + hypothesis>=3.56 nose mock requests @@ -53,7 +53,7 @@ deps = pytest-xdist>=1.13 mock nose - hypothesis>=3.5.2 + hypothesis>=3.56 changedir=testing commands = pytest -n8 -ra {posargs:.} @@ -78,7 +78,7 @@ commands = {[testenv:py27-pexpect]commands} [testenv:py27-nobyte] deps = pytest-xdist>=1.13 - hypothesis>=3.5.2 + hypothesis>=3.56 distribute = true changedir=testing setenv =