Merge pull request #3490 from nicoddemus/merge-master-into-features

Merge master into features
This commit is contained in:
Ronny Pfannschmidt 2018-05-19 11:36:11 +02:00 committed by GitHub
commit 4aa7ebaf52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
53 changed files with 138 additions and 102 deletions

View File

@ -23,6 +23,7 @@ Antony Lee
Armin Rigo Armin Rigo
Aron Coyle Aron Coyle
Aron Curzon Aron Curzon
Aviral Verma
Aviv Palivoda Aviv Palivoda
Barney Gale Barney Gale
Ben Webb Ben Webb

View File

@ -114,7 +114,7 @@ Features
- Captured log messages are added to the ``<system-out>`` tag in the generated - Captured log messages are added to the ``<system-out>`` tag in the generated
junit xml file if the ``junit_logging`` ini option is set to ``system-out``. 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
``<system-err>``. The default value for ``junit_logging`` is ``no``, meaning ``<system-err>``. The default value for ``junit_logging`` is ``no``, meaning
captured logs are not written to the output file. (`#3156 captured logs are not written to the output file. (`#3156
<https://github.com/pytest-dev/pytest/issues/3156>`_) <https://github.com/pytest-dev/pytest/issues/3156>`_)
@ -1206,7 +1206,7 @@ Changes
* Testcase reports with a ``url`` attribute will now properly write this to junitxml. * Testcase reports with a ``url`` attribute will now properly write this to junitxml.
Thanks `@fushi`_ for the PR (`#1874`_). 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 the truncation message to make it clearer that pytest truncates all
assertion messages if verbosity < 2 (`#1512`_). assertion messages if verbosity < 2 (`#1512`_).
Thanks `@mattduck`_ for the PR Thanks `@mattduck`_ for the PR
@ -1218,7 +1218,7 @@ Changes
* fix `#2013`_: turn RecordedWarning into ``namedtuple``, * fix `#2013`_: turn RecordedWarning into ``namedtuple``,
to give it a comprehensible repr while preventing unwarranted modification. 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. Thanks `@RonnyPfannschmidt`_ for the report and PR.
* Hooks are now verified after collection is complete, rather than right after loading installed plugins. This * 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`_). Notably, importing the ``anydbm`` module is fixed. (`#2248`_).
Thanks `@pfhayes`_ for the PR. 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. element in the XML report. Thanks `@kkoukiou`_ for the PR.
* Fix regression, pytest now skips unittest correctly if run with ``--pdb`` * 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) "::" node id specifications (copy pasted from "-v" output)
- fix issue544 by only removing "@NUM" at the end of "::" separated parts - 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. - don't use py.std import helper, rather import things directly.
Thanks Bruno Oliveira. 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 would not work correctly because pytest assumes @pytest.mark.some
gets a function to be decorated already. We now at least detect if this 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. for bringing it up.
- xfail a test on pypy that checks wrong encoding/ascii (pypy does - 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: rather use the post-2.0 parametrize features instead of yield, see:
http://pytest.org/latest/example/parametrize.html http://pytest.org/latest/example/parametrize.html
- fix autouse-issue where autouse-fixtures would not be discovered - 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 issue226 - LIFO ordering for fixture teardowns
- fix issue224 - invocations with >256 char arguments now work - fix issue224 - invocations with >256 char arguments now work
- fix issue91 - add/discuss package/directory level setups in example - 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 - make path.bestrelpath(path) return ".", note that when calling
X.bestrelpath the assumption is that X is a directory. X.bestrelpath the assumption is that X is a directory.
- make initial conftest discovery ignore "--" prefixed arguments - 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) (thanks Jakub Gustak)
- perform distributed testing related reporting in the xdist-plugin - perform distributed testing related reporting in the xdist-plugin
rather than having dist-related code in the generic py.test rather than having dist-related code in the generic py.test

View File

@ -6,13 +6,13 @@
------ ------
.. image:: https://img.shields.io/pypi/v/pytest.svg .. 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 :target: https://anaconda.org/conda-forge/pytest
.. image:: https://img.shields.io/pypi/pyversions/pytest.svg .. 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 .. image:: https://img.shields.io/coveralls/pytest-dev/pytest/master.svg
:target: https://coveralls.io/r/pytest-dev/pytest :target: https://coveralls.io/r/pytest-dev/pytest

View File

@ -14,7 +14,7 @@ cpy_compile = compile
class Source(object): class Source(object):
""" a immutable object holding a source code fragment, """ an immutable object holding a source code fragment,
possibly deindenting it. possibly deindenting it.
""" """
_compilecounter = 0 _compilecounter = 0

View File

@ -171,10 +171,22 @@ def _diff_text(left, right, verbose=False):
""" """
from difflib import ndiff from difflib import ndiff
explanation = [] 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): 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): 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: if not verbose:
i = 0 # just in case left or right has zero length i = 0 # just in case left or right has zero length
for i in range(min(len(left), len(right))): for i in range(min(len(left), len(right))):
@ -197,6 +209,10 @@ def _diff_text(left, right, verbose=False):
left = left[:-i] left = left[:-i]
right = right[:-i] right = right[:-i]
keepends = True 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') explanation += [line.strip('\n')
for line in ndiff(left.splitlines(keepends), for line in ndiff(left.splitlines(keepends),
right.splitlines(keepends))] right.splitlines(keepends))]

View File

@ -315,7 +315,7 @@ class CaptureFixture(object):
def safe_text_dupfile(f, mode, default_encoding="UTF8"): 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. FD-level if possible.
""" """
encoding = getattr(f, "encoding", None) encoding = getattr(f, "encoding", None)

View File

@ -257,7 +257,7 @@ def safe_getattr(object, name, default):
def _is_unittest_unexpected_success_a_failure(): 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: 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 Changed in version 3.4: Returns False if there were any

View File

@ -24,7 +24,7 @@ DOCTEST_REPORT_CHOICES = (
DOCTEST_REPORT_CHOICE_ONLY_FIRST_FAILURE, DOCTEST_REPORT_CHOICE_ONLY_FIRST_FAILURE,
) )
# Lazy definiton of runner class # Lazy definition of runner class
RUNNER_CLASS = None RUNNER_CLASS = None

View File

@ -291,7 +291,7 @@ class FixtureRequest(FuncargnamesCompatAttr):
def _getnextfixturedef(self, argname): def _getnextfixturedef(self, argname):
fixturedefs = self._arg2fixturedefs.get(argname, None) fixturedefs = self._arg2fixturedefs.get(argname, None)
if fixturedefs is 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 # getfixturevalue(argname) usage which was naturally
# not known at parsing/collection time # not known at parsing/collection time
parentid = self._pyfuncitem.parent.nodeid parentid = self._pyfuncitem.parent.nodeid
@ -1028,7 +1028,7 @@ class FixtureManager(object):
def getfixtureclosure(self, fixturenames, parentnode): def getfixtureclosure(self, fixturenames, parentnode):
# collect the closure of all fixtures , starting with the given # collect the closure of all fixtures , starting with the given
# fixturenames as the initial set. As we have to visit all # 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 # mapping so that the caller can reuse it and does not have
# to re-discover fixturedefs again for each fixturename # to re-discover fixturedefs again for each fixturename
# (discovering matching fixtures for a given name/node is expensive) # (discovering matching fixtures for a given name/node is expensive)

View File

@ -7,7 +7,7 @@ from __future__ import absolute_import, division, print_function
def freeze_includes(): 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. included by cx_freeze.
""" """
import py import py

View File

@ -90,7 +90,7 @@ def pytest_addoption(parser):
def pytest_configure(config): def pytest_configure(config):
__import__('pytest').config = config # compatibiltiy __import__('pytest').config = config # compatibility
def wrap_session(config, doit): def wrap_session(config, doit):
@ -290,7 +290,7 @@ class Interrupted(KeyboardInterrupt):
class Failed(Exception): class Failed(Exception):
""" signals an stop as failed test run. """ """ signals a stop as failed test run. """
class Session(nodes.FSCollector): class Session(nodes.FSCollector):

View File

@ -215,7 +215,7 @@ class MarkDecorator(object):
def get_unpacked_marks(obj): 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', []) mark_list = getattr(obj, 'pytestmark', [])
@ -228,7 +228,7 @@ def get_unpacked_marks(obj):
def store_mark(obj, mark): 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 this is used to implement the Mark declarations/decorators correctly
""" """
assert isinstance(mark, Mark), mark assert isinstance(mark, Mark), mark

View File

@ -83,7 +83,7 @@ skip.Exception = Skipped
def fail(msg="", pytrace=True): 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 :arg pytrace: if false the msg represents the full failure information
and no python traceback will be reported. and no python traceback will be reported.

View File

@ -714,7 +714,7 @@ class Testdir(object):
""" """
finalizers = [] finalizers = []
try: 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 # process are already imported. So this disables the warning which
# will trigger to say they can no longer be rewritten, which is # will trigger to say they can no longer be rewritten, which is
# fine as they have already been rewritten. # fine as they have already been rewritten.
@ -725,7 +725,7 @@ class Testdir(object):
finalizers.append(revert_warn_already_imported) finalizers.append(revert_warn_already_imported)
AssertionRewritingHook._warn_already_imported = lambda *a: None 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 # inline should be reverted after the test run completes to avoid
# clashing with later inline tests run within the same pytest test, # clashing with later inline tests run within the same pytest test,
# e.g. just because they use matching test module names. # e.g. just because they use matching test module names.

View File

@ -55,7 +55,7 @@ def filter_traceback(entry):
is_generated = '<' in raw_filename and '>' in raw_filename is_generated = '<' in raw_filename and '>' in raw_filename
if is_generated: if is_generated:
return False 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 # also return a str object. see #1133
p = py.path.local(entry.path) p = py.path.local(entry.path)
return not p.relto(_pluggy_dir) and not p.relto(_pytest_dir) and not p.relto(_py_dir) return not p.relto(_pluggy_dir) and not p.relto(_pytest_dir) and not p.relto(_py_dir)

1
changelog/3303.doc.rst Normal file
View File

@ -0,0 +1 @@
Change documentation copyright year to a range which auto-updates itself each time it is published.

View File

@ -0,0 +1 @@
Update all pypi.python.org URLs to pypi.org.

View File

@ -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.

View File

@ -1,6 +1,6 @@
<h3>Useful Links</h3> <h3>Useful Links</h3>
<ul> <ul>
<li><a href="https://pypi.python.org/pypi/pytest">pytest @ PyPI</a></li> <li><a href="https://pypi.org/project/pytest/">pytest @ PyPI</a></li>
<li><a href="https://github.com/pytest-dev/pytest/">pytest @ GitHub</a></li> <li><a href="https://github.com/pytest-dev/pytest/">pytest @ GitHub</a></li>
<li><a href="http://plugincompat.herokuapp.com/">3rd party plugins</a></li> <li><a href="http://plugincompat.herokuapp.com/">3rd party plugins</a></li>
<li><a href="https://github.com/pytest-dev/pytest/issues">Issue Tracker</a></li> <li><a href="https://github.com/pytest-dev/pytest/issues">Issue Tracker</a></li>

View File

@ -18,7 +18,7 @@ comes with the following fixes and features:
rather use the post-2.0 parametrize features instead of yield, see: rather use the post-2.0 parametrize features instead of yield, see:
http://pytest.org/latest/example/parametrize.html http://pytest.org/latest/example/parametrize.html
- fix autouse-issue where autouse-fixtures would not be discovered - 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 issue226 - LIFO ordering for fixture teardowns
- fix issue224 - invocations with >256 char arguments now work - fix issue224 - invocations with >256 char arguments now work
- fix issue91 - add/discuss package/directory level setups in example - fix issue91 - add/discuss package/directory level setups in example

View File

@ -14,7 +14,7 @@ few interesting new plugins saw the light last month:
And several others like pytest-django saw maintenance releases. And several others like pytest-django saw maintenance releases.
For a more complete list, check out 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: For general information see:

View File

@ -23,14 +23,14 @@ a full list of details. A few feature highlights:
called if the corresponding setup method succeeded. called if the corresponding setup method succeeded.
- integrate tab-completion on command line options if you - integrate tab-completion on command line options if you
have `argcomplete <http://pypi.python.org/pypi/argcomplete>`_ have `argcomplete <https://pypi.org/project/argcomplete/>`_
configured. configured.
- allow boolean expression directly with skipif/xfail - allow boolean expression directly with skipif/xfail
if a "reason" is also specified. if a "reason" is also specified.
- a new hook ``pytest_load_initial_conftests`` allows plugins like - a new hook ``pytest_load_initial_conftests`` allows plugins like
`pytest-django <http://pypi.python.org/pypi/pytest-django>`_ to `pytest-django <https://pypi.org/project/pytest-django/>`_ to
influence the environment before conftest files import ``django``. influence the environment before conftest files import ``django``.
- reporting: color the last line red or green depending if - reporting: color the last line red or green depending if

View File

@ -52,7 +52,7 @@ Changes 2.6.1
"::" node id specifications (copy pasted from "-v" output) "::" node id specifications (copy pasted from "-v" output)
- fix issue544 by only removing "@NUM" at the end of "::" separated parts - 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. - don't use py.std import helper, rather import things directly.
Thanks Bruno Oliveira. Thanks Bruno Oliveira.

View File

@ -234,7 +234,7 @@ Inspecting Cache content
You can always peek at the content of the cache using the You can always peek at the content of the cache using the
``--cache-show`` command line option:: ``--cache-show`` command line option::
$ py.test --cache-show $ pytest --cache-show
=========================== test session starts ============================ =========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y
rootdir: $REGENDOC_TMPDIR, inifile: rootdir: $REGENDOC_TMPDIR, inifile:

View File

@ -20,6 +20,7 @@
import os import os
import sys import sys
import datetime
from _pytest import __version__ as version from _pytest import __version__ as version
@ -57,7 +58,8 @@ master_doc = 'contents'
# General information about the project. # General information about the project.
project = u'pytest' 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)

View File

@ -10,7 +10,7 @@ Code Style
---------- ----------
* `PEP-8 <https://www.python.org/dev/peps/pep-0008>`_ * `PEP-8 <https://www.python.org/dev/peps/pep-0008>`_
* `flake8 <https://pypi.python.org/pypi/flake8>`_ for quality checks * `flake8 <https://pypi.org/project/flake8/>`_ for quality checks
* `invoke <http://www.pyinvoke.org/>`_ to automate development tasks * `invoke <http://www.pyinvoke.org/>`_ to automate development tasks

View File

@ -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 .. _`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: 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:

View File

@ -160,7 +160,7 @@ together with the actual data, instead of listing them separately.
A quick port of "testscenarios" 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`_, Here is a quick port to run tests configured with `test scenarios`_,
an add-on from Robert Collins for the standard unittest framework. We 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 ==================== =================== 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: of our ``test_func1`` was skipped. A few notes:
- the fixture functions in the ``conftest.py`` file are "session-scoped" because we - the fixture functions in the ``conftest.py`` file are "session-scoped" because we

View File

@ -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. Default behavior of ``pytest`` is to ignore duplicate paths specified from the command line.
Example:: Example::
py.test path_a path_a pytest path_a path_a
... ...
collected 1 item collected 1 item
@ -65,7 +65,7 @@ Just collect tests once.
To collect duplicate tests, use the ``--keep-duplicates`` option on the cli. To collect duplicate tests, use the ``--keep-duplicates`` option on the cli.
Example:: Example::
py.test --keep-duplicates path_a path_a pytest --keep-duplicates path_a path_a
... ...
collected 2 items 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. still collect it twice, no matter if the ``--keep-duplicates`` is not specified.
Example:: Example::
py.test test_a.py test_a.py pytest test_a.py test_a.py
... ...
collected 2 items collected 2 items

View File

@ -108,7 +108,7 @@ the command line arguments before they get processed:
num = max(multiprocessing.cpu_count() / 2, 1) num = max(multiprocessing.cpu_count() / 2, 1)
args[:] = ["-n", str(num)] + args args[:] = ["-n", str(num)] + args
If you have the `xdist plugin <https://pypi.python.org/pypi/pytest-xdist>`_ installed If you have the `xdist plugin <https://pypi.org/project/pytest-xdist/>`_ installed
you will now always perform test runs using a number you will now always perform test runs using a number
of subprocesses close to your CPU. Running in an empty of subprocesses close to your CPU. Running in an empty
directory with the above conftest.py:: 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. 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 ``pytest`` sets a ``PYTEST_CURRENT_TEST`` environment variable when running tests, which can be inspected
by process monitoring utilities or libraries like `psutil <https://pypi.python.org/pypi/psutil>`_ to discover which by process monitoring utilities or libraries like `psutil <https://pypi.org/project/psutil/>`_ to discover which
test got stuck if necessary: test got stuck if necessary:
.. code-block:: python .. code-block:: python

View File

@ -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 If you are using trial's unittest.TestCase chances are that you can
just run your tests even if you return Deferreds. In addition, just run your tests even if you return Deferreds. In addition,
there also is a dedicated `pytest-twisted there also is a dedicated `pytest-twisted
<http://pypi.python.org/pypi/pytest-twisted>`_ plugin which allows you to <https://pypi.org/project/pytest-twisted/>`_ plugin which allows you to
return deferreds from pytest-style tests, allowing the use of return deferreds from pytest-style tests, allowing the use of
:ref:`fixtures` and other features. :ref:`fixtures` and other features.
how does pytest work with Django? how does pytest work with Django?
++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++
In 2012, some work is going into the `pytest-django plugin <http://pypi.python.org/pypi/pytest-django>`_. It substitutes the usage of Django's In 2012, some work is going into the `pytest-django plugin <https://pypi.org/project/pytest-django/>`_. It substitutes the usage of Django's
``manage.py test`` and allows the use of all pytest features_ most of which ``manage.py test`` and allows the use of all pytest features_ most of which
are not available from Django directly. are not available from Django directly.

View File

@ -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. 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 There are also community plugins available to help managing this aspect of
testing, e.g. `pytest-datadir <https://github.com/gabrielcnr/pytest-datadir>`__ testing, e.g. `pytest-datadir <https://github.com/gabrielcnr/pytest-datadir>`__
and `pytest-datafiles <https://pypi.python.org/pypi/pytest-datafiles>`__. and `pytest-datafiles <https://pypi.org/project/pytest-datafiles/>`__.
.. _smtpshared: .. _smtpshared:

View File

@ -5,10 +5,10 @@ Installation and Getting Started
**Platforms**: Unix/Posix and Windows **Platforms**: Unix/Posix and Windows
**PyPI package name**: `pytest <http://pypi.python.org/pypi/pytest>`_ **PyPI package name**: `pytest <https://pypi.org/project/pytest/>`_
**Dependencies**: `py <http://pypi.python.org/pypi/py>`_, **Dependencies**: `py <https://pypi.org/project/py/>`_,
`colorama (Windows) <http://pypi.python.org/pypi/colorama>`_, `colorama (Windows) <https://pypi.org/project/colorama/>`_,
**Documentation as PDF**: `download latest <https://media.readthedocs.org/pdf/pytest/latest/pytest.pdf>`_ **Documentation as PDF**: `download latest <https://media.readthedocs.org/pdf/pytest/latest/pytest.pdf>`_

View File

@ -145,7 +145,7 @@ Note that this layout also works in conjunction with the ``src`` layout mentione
.. note:: .. 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 recursing into the filesystem it determines the import name
as follows: 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. 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/ .. _`buildout`: http://www.buildout.org/
.. _pip: http://pypi.python.org/pypi/pip .. _pip: https://pypi.org/project/pip/
.. _`use tox`: .. _`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 You can integrate test runs into your setuptools based project
with the `pytest-runner <https://pypi.python.org/pypi/pytest-runner>`_ plugin. with the `pytest-runner <https://pypi.org/project/pytest-runner/>`_ plugin.
Add this to ``setup.py`` file: Add this to ``setup.py`` file:

View File

@ -7,14 +7,14 @@
.. _`reStructured Text`: http://docutils.sourceforge.net .. _`reStructured Text`: http://docutils.sourceforge.net
.. _`Python debugger`: http://docs.python.org/lib/module-pdb.html .. _`Python debugger`: http://docs.python.org/lib/module-pdb.html
.. _nose: https://nose.readthedocs.io/en/latest/ .. _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/ .. _mercurial: http://mercurial.selenic.com/wiki/
.. _`setuptools`: http://pypi.python.org/pypi/setuptools .. _`setuptools`: https://pypi.org/project/setuptools/
.. _`easy_install`: .. _`easy_install`:
.. _`distribute docs`: .. _`distribute docs`:
.. _`distribute`: http://pypi.python.org/pypi/distribute .. _`distribute`: https://pypi.org/project/distribute/
.. _`pip`: http://pypi.python.org/pypi/pip .. _`pip`: https://pypi.org/project/pip/
.. _`virtualenv`: http://pypi.python.org/pypi/virtualenv .. _`virtualenv`: https://pypi.org/project/virtualenv/
.. _hudson: http://hudson-ci.org/ .. _hudson: http://hudson-ci.org/
.. _jenkins: http://jenkins-ci.org/ .. _jenkins: http://jenkins-ci.org/
.. _tox: http://testrun.org/tox .. _tox: http://testrun.org/tox

View File

@ -20,39 +20,39 @@ Here is a little annotated list for some popular plugins:
.. _`django`: https://www.djangoproject.com/ .. _`django`: https://www.djangoproject.com/
* `pytest-django <http://pypi.python.org/pypi/pytest-django>`_: write tests * `pytest-django <https://pypi.org/project/pytest-django/>`_: write tests
for `django`_ apps, using pytest integration. for `django`_ apps, using pytest integration.
* `pytest-twisted <http://pypi.python.org/pypi/pytest-twisted>`_: write tests * `pytest-twisted <https://pypi.org/project/pytest-twisted/>`_: write tests
for `twisted <http://twistedmatrix.com>`_ apps, starting a reactor and for `twisted <http://twistedmatrix.com>`_ apps, starting a reactor and
processing deferreds from test functions. processing deferreds from test functions.
* `pytest-cov <http://pypi.python.org/pypi/pytest-cov>`_: * `pytest-cov <https://pypi.org/project/pytest-cov/>`_:
coverage reporting, compatible with distributed testing coverage reporting, compatible with distributed testing
* `pytest-xdist <http://pypi.python.org/pypi/pytest-xdist>`_: * `pytest-xdist <https://pypi.org/project/pytest-xdist/>`_:
to distribute tests to CPUs and remote hosts, to run in boxed to distribute tests to CPUs and remote hosts, to run in boxed
mode which allows to survive segmentation faults, to run in mode which allows to survive segmentation faults, to run in
looponfailing mode, automatically re-running failing tests looponfailing mode, automatically re-running failing tests
on file changes. on file changes.
* `pytest-instafail <http://pypi.python.org/pypi/pytest-instafail>`_: * `pytest-instafail <https://pypi.org/project/pytest-instafail/>`_:
to report failures while the test run is happening. to report failures while the test run is happening.
* `pytest-bdd <http://pypi.python.org/pypi/pytest-bdd>`_ and * `pytest-bdd <https://pypi.org/project/pytest-bdd/>`_ and
`pytest-konira <http://pypi.python.org/pypi/pytest-konira>`_ `pytest-konira <https://pypi.org/project/pytest-konira/>`_
to write tests using behaviour-driven testing. to write tests using behaviour-driven testing.
* `pytest-timeout <http://pypi.python.org/pypi/pytest-timeout>`_: * `pytest-timeout <https://pypi.org/project/pytest-timeout/>`_:
to timeout tests based on function marks or global definitions. to timeout tests based on function marks or global definitions.
* `pytest-pep8 <http://pypi.python.org/pypi/pytest-pep8>`_: * `pytest-pep8 <https://pypi.org/project/pytest-pep8/>`_:
a ``--pep8`` option to enable PEP8 compliance checking. a ``--pep8`` option to enable PEP8 compliance checking.
* `pytest-flakes <https://pypi.python.org/pypi/pytest-flakes>`_: * `pytest-flakes <https://pypi.org/project/pytest-flakes/>`_:
check source code with pyflakes. check source code with pyflakes.
* `oejskit <http://pypi.python.org/pypi/oejskit>`_: * `oejskit <https://pypi.org/project/oejskit/>`_:
a plugin to run javascript unittests in live browsers. a plugin to run javascript unittests in live browsers.
To see a complete list of all plugins with their latest testing 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`_. 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`: .. _`available installable plugins`:

View File

@ -32,40 +32,40 @@ Here are some examples of projects using ``pytest`` (please send notes via :ref:
* `PyPM <http://code.activestate.com/pypm/>`_ ActiveState's package manager * `PyPM <http://code.activestate.com/pypm/>`_ ActiveState's package manager
* `Fom <http://packages.python.org/Fom/>`_ a fluid object mapper for FluidDB * `Fom <http://packages.python.org/Fom/>`_ a fluid object mapper for FluidDB
* `applib <https://github.com/ActiveState/applib>`_ cross-platform utilities * `applib <https://github.com/ActiveState/applib>`_ cross-platform utilities
* `six <http://pypi.python.org/pypi/six/>`_ Python 2 and 3 compatibility utilities * `six <https://pypi.org/project/six/>`_ Python 2 and 3 compatibility utilities
* `pediapress <http://code.pediapress.com/wiki/wiki>`_ MediaWiki articles * `pediapress <http://code.pediapress.com/wiki/wiki>`_ MediaWiki articles
* `mwlib <http://pypi.python.org/pypi/mwlib>`_ mediawiki parser and utility library * `mwlib <https://pypi.org/project/mwlib/>`_ mediawiki parser and utility library
* `The Translate Toolkit <http://translate.sourceforge.net/wiki/toolkit/index>`_ for localization and conversion * `The Translate Toolkit <http://translate.sourceforge.net/wiki/toolkit/index>`_ for localization and conversion
* `execnet <http://codespeak.net/execnet>`_ rapid multi-Python deployment * `execnet <http://codespeak.net/execnet>`_ rapid multi-Python deployment
* `pylib <https://py.readthedocs.io>`_ cross-platform path, IO, dynamic code library * `pylib <https://py.readthedocs.io>`_ cross-platform path, IO, dynamic code library
* `Pacha <http://pacha.cafepais.com/>`_ configuration management in five minutes * `Pacha <http://pacha.cafepais.com/>`_ configuration management in five minutes
* `bbfreeze <http://pypi.python.org/pypi/bbfreeze>`_ create standalone executables from Python scripts * `bbfreeze <https://pypi.org/project/bbfreeze/>`_ create standalone executables from Python scripts
* `pdb++ <http://bitbucket.org/antocuni/pdb>`_ a fancier version of PDB * `pdb++ <http://bitbucket.org/antocuni/pdb>`_ a fancier version of PDB
* `py-s3fuse <http://code.google.com/p/py-s3fuse/>`_ Amazon S3 FUSE based filesystem * `py-s3fuse <http://code.google.com/p/py-s3fuse/>`_ Amazon S3 FUSE based filesystem
* `waskr <http://code.google.com/p/waskr/>`_ WSGI Stats Middleware * `waskr <http://code.google.com/p/waskr/>`_ WSGI Stats Middleware
* `guachi <http://code.google.com/p/guachi/>`_ global persistent configs for Python modules * `guachi <http://code.google.com/p/guachi/>`_ global persistent configs for Python modules
* `Circuits <http://pypi.python.org/pypi/circuits>`_ lightweight Event Driven Framework * `Circuits <https://pypi.org/project/circuits/>`_ lightweight Event Driven Framework
* `pygtk-helpers <http://bitbucket.org/aafshar/pygtkhelpers-main/>`_ easy interaction with PyGTK * `pygtk-helpers <http://bitbucket.org/aafshar/pygtkhelpers-main/>`_ easy interaction with PyGTK
* `QuantumCore <http://quantumcore.org/>`_ statusmessage and repoze openid plugin * `QuantumCore <http://quantumcore.org/>`_ statusmessage and repoze openid plugin
* `pydataportability <http://pydataportability.net/>`_ libraries for managing the open web * `pydataportability <http://pydataportability.net/>`_ libraries for managing the open web
* `XIST <http://www.livinglogic.de/Python/xist/>`_ extensible HTML/XML generator * `XIST <http://www.livinglogic.de/Python/xist/>`_ extensible HTML/XML generator
* `tiddlyweb <http://pypi.python.org/pypi/tiddlyweb>`_ optionally headless, extensible RESTful datastore * `tiddlyweb <https://pypi.org/project/tiddlyweb/>`_ optionally headless, extensible RESTful datastore
* `fancycompleter <http://bitbucket.org/antocuni/fancycompleter/src>`_ for colorful tab-completion * `fancycompleter <http://bitbucket.org/antocuni/fancycompleter/src>`_ for colorful tab-completion
* `Paludis <http://paludis.exherbo.org/>`_ tools for Gentoo Paludis package manager * `Paludis <http://paludis.exherbo.org/>`_ tools for Gentoo Paludis package manager
* `Gerald <http://halfcooked.com/code/gerald/>`_ schema comparison tool * `Gerald <http://halfcooked.com/code/gerald/>`_ schema comparison tool
* `abjad <http://code.google.com/p/abjad/>`_ Python API for Formalized Score control * `abjad <http://code.google.com/p/abjad/>`_ Python API for Formalized Score control
* `bu <http://packages.python.org/bu/>`_ a microscopic build system * `bu <http://packages.python.org/bu/>`_ a microscopic build system
* `katcp <https://bitbucket.org/hodgestar/katcp>`_ Telescope communication protocol over Twisted * `katcp <https://bitbucket.org/hodgestar/katcp>`_ Telescope communication protocol over Twisted
* `kss plugin timer <http://pypi.python.org/pypi/kss.plugin.timer>`_ * `kss plugin timer <https://pypi.org/project/kss.plugin.timer/>`_
* `pyudev <https://pyudev.readthedocs.io/en/latest/tests/plugins.html>`_ a pure Python binding to the Linux library libudev * `pyudev <https://pyudev.readthedocs.io/en/latest/tests/plugins.html>`_ a pure Python binding to the Linux library libudev
* `pytest-localserver <https://bitbucket.org/pytest-dev/pytest-localserver/>`_ a plugin for pytest that provides an httpserver and smtpserver * `pytest-localserver <https://bitbucket.org/pytest-dev/pytest-localserver/>`_ a plugin for pytest that provides an httpserver and smtpserver
* `pytest-monkeyplus <http://pypi.python.org/pypi/pytest-monkeyplus/>`_ a plugin that extends monkeypatch * `pytest-monkeyplus <https://pypi.org/project/pytest-monkeyplus/>`_ a plugin that extends monkeypatch
These projects help integrate ``pytest`` into other Python frameworks: These projects help integrate ``pytest`` into other Python frameworks:
* `pytest-django <http://pypi.python.org/pypi/pytest-django/>`_ for Django * `pytest-django <https://pypi.org/project/pytest-django/>`_ for Django
* `zope.pytest <http://packages.python.org/zope.pytest/>`_ for Zope and Grok * `zope.pytest <http://packages.python.org/zope.pytest/>`_ for Zope and Grok
* `pytest_gae <http://pypi.python.org/pypi/pytest_gae/0.2.1>`_ for Google App Engine * `pytest_gae <https://pypi.org/project/pytest_gae/0.2.1/>`_ for Google App Engine
* There is `some work <https://github.com/Kotti/Kotti/blob/master/kotti/testing.py>`_ underway for Kotti, a CMS built in Pyramid/Pylons * There is `some work <https://github.com/Kotti/Kotti/blob/master/kotti/testing.py>`_ underway for Kotti, a CMS built in Pyramid/Pylons

View File

@ -118,7 +118,7 @@ all parameters marked as a fixture.
.. note:: .. note::
The `pytest-lazy-fixture <https://pypi.python.org/pypi/pytest-lazy-fixture>`_ plugin implements a very The `pytest-lazy-fixture <https://pypi.org/project/pytest-lazy-fixture/>`_ plugin implements a very
similar solution to the proposal below, make sure to check it out. similar solution to the proposal below, make sure to check it out.
.. code-block:: python .. code-block:: python

View File

@ -150,7 +150,7 @@ Unconditionally skip a test function.
pytest.mark.skipif pytest.mark.skipif
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
**Tutorial**: :ref:`xfail`. **Tutorial**: :ref:`skipif`.
Skip a test function if a condition is ``True``. 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 Allows to pick the action for empty parametersets in parameterization
* ``skip`` skips tests with a empty parameterset (default) * ``skip`` skips tests with an empty parameterset (default)
* ``xfail`` marks tests with a empty parameterset as xfail(run=False) * ``xfail`` marks tests with an empty parameterset as xfail(run=False)
.. code-block:: ini .. code-block:: ini

View File

@ -21,7 +21,7 @@ The `pytest-cov`_ package may be installed with pip or easy_install::
pip install pytest-cov pip install pytest-cov
easy_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 Uninstallation

View File

@ -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. For more info and download please visit the `oejskit PyPI`_ page.
.. _`oejskit`: .. _`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', .. source link 'http://bitbucket.org/pedronis/js-infrastructure/src/tip/pytest_jstests.py',

View File

@ -26,7 +26,7 @@ program source code to the remote place. All test results
are reported back and displayed to your local test session. are reported back and displayed to your local test session.
You may specify different Python versions and interpreters. 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 Usage examples
--------------------- ---------------------

View File

@ -46,9 +46,9 @@ in most cases without having to modify existing code:
* :ref:`maxfail`; * :ref:`maxfail`;
* :ref:`--pdb <pdb-option>` command-line option for debugging on test failures * :ref:`--pdb <pdb-option>` command-line option for debugging on test failures
(see :ref:`note <pdb-unittest-note>` below); (see :ref:`note <pdb-unittest-note>` below);
* Distribute tests to multiple CPUs using the `pytest-xdist <http://pypi.python.org/pypi/pytest-xdist>`_ plugin; * Distribute tests to multiple CPUs using the `pytest-xdist <https://pypi.org/project/pytest-xdist/>`_ plugin;
* Use :ref:`plain assert-statements <assert>` instead of ``self.assert*`` functions (`unittest2pytest * Use :ref:`plain assert-statements <assert>` instead of ``self.assert*`` functions (`unittest2pytest
<https://pypi.python.org/pypi/unittest2pytest/>`__ is immensely helpful in this); <https://pypi.org/project/unittest2pytest/>`__ is immensely helpful in this);
pytest features in ``unittest.TestCase`` subclasses pytest features in ``unittest.TestCase`` subclasses

View File

@ -421,7 +421,7 @@ Creating resultlog format files
This option is rarely used and is scheduled for removal in 4.0. 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 An alternative for users which still need similar functionality is to use the
`pytest-tap <https://pypi.python.org/pypi/pytest-tap>`_ plugin which provides `pytest-tap <https://pypi.org/project/pytest-tap/>`_ plugin which provides
a stream of test data. a stream of test data.
If you have any concerns, please don't hesitate to If you have any concerns, please don't hesitate to

View File

@ -103,7 +103,7 @@ Here is how you might run it::
Writing your own plugin 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 If you want to write a plugin, there are many real-life examples
you can copy from: you can copy from:

View File

@ -1198,7 +1198,7 @@ def test_cwd_deleted(testdir):
def test_exception_repr_extraction_error_on_recursion(): def test_exception_repr_extraction_error_on_recursion():
""" """
Ensure we can properly detect a recursion error even 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): class numpy_like(object):

View File

@ -523,6 +523,7 @@ class TestRequestBasic(object):
testdir.makepyfile(""" testdir.makepyfile("""
import sys import sys
import pytest import pytest
from _pytest.compat import safe_str
import gc import gc
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
@ -539,7 +540,7 @@ class TestRequestBasic(object):
gc.collect() gc.collect()
leaked_types = sum(1 for _ in gc.garbage leaked_types = sum(1 for _ in gc.garbage
if 'PseudoFixtureDef' in str(_)) if 'PseudoFixtureDef' in safe_str(_))
gc.garbage[:] = [] gc.garbage[:] = []
@ -1552,7 +1553,7 @@ class TestAutouseDiscovery(object):
def test_callables_nocode(self, testdir): 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 due to it being callable and __code__ not being a code object
""" """
testdir.makepyfile(""" testdir.makepyfile("""

View File

@ -194,6 +194,7 @@ class TestMetafunc(object):
assert metafunc._calls[3].id == "x1-b" assert metafunc._calls[3].id == "x1-b"
@hypothesis.given(strategies.text() | strategies.binary()) @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): def test_idval_hypothesis(self, value):
from _pytest.python import _idval from _pytest.python import _idval
escaped = _idval(value, 'a', 6, None) escaped = _idval(value, 'a', 6, None)

View File

@ -473,7 +473,7 @@ class TestAssert_reprcompare(object):
def test_one_repr_empty(self): def test_one_repr_empty(self):
""" """
the faulty empty string repr did trigger the faulty empty string repr did trigger
a unbound local error in _diff_text an unbound local error in _diff_text
""" """
class A(str): class A(str):
def __repr__(self): def __repr__(self):
@ -746,6 +746,18 @@ def test_reprcompare_notin(mock_config):
assert detail == ["'foo' is contained here:", ' aaafoobbb', '? +++'] 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): def test_pytest_assertrepr_compare_integration(testdir):
testdir.makepyfile(""" testdir.makepyfile("""
def test_hello(): def test_hello():

View File

@ -998,7 +998,7 @@ class TestStdCapture(object):
reason='text output different for bytes on python3') reason='text output different for bytes on python3')
def test_capturing_readouterr_decode_error_handling(self): def test_capturing_readouterr_decode_error_handling(self):
with self.getcapture() as cap: with self.getcapture() as cap:
# triggered a internal error in pytest # triggered an internal error in pytest
print('\xa6') print('\xa6')
out, err = cap.readouterr() out, err = cap.readouterr()
assert out == py.builtin._totext('\ufffd\n', 'unicode-escape') assert out == py.builtin._totext('\ufffd\n', 'unicode-escape')

View File

@ -373,7 +373,7 @@ class TestConftestVisibility(object):
(None, 1, 1), (None, 1, 1),
]) ])
def test_search_conftest_up_to_inifile(testdir, confcutdir, passed, error): 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. an explicit --confcutdir option is given.
""" """
root = testdir.tmpdir root = testdir.tmpdir

View File

@ -289,7 +289,7 @@ def test_nose_setup_ordering(testdir):
def test_apiwrapper_problem_issue260(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 # for plain unittests we dont want nose behaviour
testdir.makepyfile(""" testdir.makepyfile("""
import unittest import unittest

View File

@ -20,7 +20,7 @@ envlist =
commands = pytest --lsof -ra {posargs:testing} commands = pytest --lsof -ra {posargs:testing}
passenv = USER USERNAME passenv = USER USERNAME
deps = deps =
hypothesis>=3.5.2 hypothesis>=3.56
nose nose
mock mock
requests requests
@ -53,7 +53,7 @@ deps =
pytest-xdist>=1.13 pytest-xdist>=1.13
mock mock
nose nose
hypothesis>=3.5.2 hypothesis>=3.56
changedir=testing changedir=testing
commands = commands =
pytest -n8 -ra {posargs:.} pytest -n8 -ra {posargs:.}
@ -78,7 +78,7 @@ commands = {[testenv:py27-pexpect]commands}
[testenv:py27-nobyte] [testenv:py27-nobyte]
deps = deps =
pytest-xdist>=1.13 pytest-xdist>=1.13
hypothesis>=3.5.2 hypothesis>=3.56
distribute = true distribute = true
changedir=testing changedir=testing
setenv = setenv =