Skip to content

Commit 6748799

Browse files
committed
Merge remote-tracking branch 'upstream/master' into merge-master-into-features
2 parents 35f53a7 + 45faaec commit 6748799

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+138
-102
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Antony Lee
2323
Armin Rigo
2424
Aron Coyle
2525
Aron Curzon
26+
Aviral Verma
2627
Aviv Palivoda
2728
Barney Gale
2829
Ben Webb

CHANGELOG.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ Features
114114

115115
- Captured log messages are added to the ``<system-out>`` tag in the generated
116116
junit xml file if the ``junit_logging`` ini option is set to ``system-out``.
117-
If the value of this ini option is ``system-err`, the logs are written to
117+
If the value of this ini option is ``system-err``, the logs are written to
118118
``<system-err>``. The default value for ``junit_logging`` is ``no``, meaning
119119
captured logs are not written to the output file. (`#3156
120120
<https://github.com/pytest-dev/pytest/issues/3156>`_)
@@ -1206,7 +1206,7 @@ Changes
12061206
* Testcase reports with a ``url`` attribute will now properly write this to junitxml.
12071207
Thanks `@fushi`_ for the PR (`#1874`_).
12081208

1209-
* Remove common items from dict comparision output when verbosity=1. Also update
1209+
* Remove common items from dict comparison output when verbosity=1. Also update
12101210
the truncation message to make it clearer that pytest truncates all
12111211
assertion messages if verbosity < 2 (`#1512`_).
12121212
Thanks `@mattduck`_ for the PR
@@ -1218,7 +1218,7 @@ Changes
12181218
* fix `#2013`_: turn RecordedWarning into ``namedtuple``,
12191219
to give it a comprehensible repr while preventing unwarranted modification.
12201220

1221-
* fix `#2208`_: ensure a iteration limit for _pytest.compat.get_real_func.
1221+
* fix `#2208`_: ensure an iteration limit for _pytest.compat.get_real_func.
12221222
Thanks `@RonnyPfannschmidt`_ for the report and PR.
12231223

12241224
* Hooks are now verified after collection is complete, rather than right after loading installed plugins. This
@@ -1322,7 +1322,7 @@ Bug Fixes
13221322
Notably, importing the ``anydbm`` module is fixed. (`#2248`_).
13231323
Thanks `@pfhayes`_ for the PR.
13241324

1325-
* junitxml: Fix problematic case where system-out tag occured twice per testcase
1325+
* junitxml: Fix problematic case where system-out tag occurred twice per testcase
13261326
element in the XML report. Thanks `@kkoukiou`_ for the PR.
13271327

13281328
* 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
29182918
"::" node id specifications (copy pasted from "-v" output)
29192919

29202920
- fix issue544 by only removing "@NUM" at the end of "::" separated parts
2921-
and if the part has an ".py" extension
2921+
and if the part has a ".py" extension
29222922

29232923
- don't use py.std import helper, rather import things directly.
29242924
Thanks Bruno Oliveira.
@@ -3189,7 +3189,7 @@ time or change existing behaviors in order to make them less surprising/more use
31893189

31903190
would not work correctly because pytest assumes @pytest.mark.some
31913191
gets a function to be decorated already. We now at least detect if this
3192-
arg is an lambda and thus the example will work. Thanks Alex Gaynor
3192+
arg is a lambda and thus the example will work. Thanks Alex Gaynor
31933193
for bringing it up.
31943194

31953195
- xfail a test on pypy that checks wrong encoding/ascii (pypy does
@@ -3502,7 +3502,7 @@ Bug fixes:
35023502
rather use the post-2.0 parametrize features instead of yield, see:
35033503
http://pytest.org/latest/example/parametrize.html
35043504
- fix autouse-issue where autouse-fixtures would not be discovered
3505-
if defined in a a/conftest.py file and tests in a/tests/test_some.py
3505+
if defined in an a/conftest.py file and tests in a/tests/test_some.py
35063506
- fix issue226 - LIFO ordering for fixture teardowns
35073507
- fix issue224 - invocations with >256 char arguments now work
35083508
- fix issue91 - add/discuss package/directory level setups in example
@@ -4072,7 +4072,7 @@ Bug fixes:
40724072
- make path.bestrelpath(path) return ".", note that when calling
40734073
X.bestrelpath the assumption is that X is a directory.
40744074
- make initial conftest discovery ignore "--" prefixed arguments
4075-
- fix resultlog plugin when used in an multicpu/multihost xdist situation
4075+
- fix resultlog plugin when used in a multicpu/multihost xdist situation
40764076
(thanks Jakub Gustak)
40774077
- perform distributed testing related reporting in the xdist-plugin
40784078
rather than having dist-related code in the generic py.test

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
------
77

88
.. image:: https://img.shields.io/pypi/v/pytest.svg
9-
:target: https://pypi.python.org/pypi/pytest
9+
:target: https://pypi.org/project/pytest/
1010

11-
.. image:: https://anaconda.org/conda-forge/pytest/badges/version.svg
11+
.. image:: https://img.shields.io/conda/vn/conda-forge/pytest.svg
1212
:target: https://anaconda.org/conda-forge/pytest
1313

1414
.. image:: https://img.shields.io/pypi/pyversions/pytest.svg
15-
:target: https://pypi.python.org/pypi/pytest
15+
:target: https://pypi.org/project/pytest/
1616

1717
.. image:: https://img.shields.io/coveralls/pytest-dev/pytest/master.svg
1818
:target: https://coveralls.io/r/pytest-dev/pytest

_pytest/_code/source.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515

1616
class Source(object):
17-
""" a immutable object holding a source code fragment,
17+
""" an immutable object holding a source code fragment,
1818
possibly deindenting it.
1919
"""
2020
_compilecounter = 0

_pytest/assertion/util.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,22 @@ def _diff_text(left, right, verbose=False):
171171
"""
172172
from difflib import ndiff
173173
explanation = []
174+
175+
def escape_for_readable_diff(binary_text):
176+
"""
177+
Ensures that the internal string is always valid unicode, converting any bytes safely to valid unicode.
178+
This is done using repr() which then needs post-processing to fix the encompassing quotes and un-escape
179+
newlines and carriage returns (#429).
180+
"""
181+
r = six.text_type(repr(binary_text)[1:-1])
182+
r = r.replace(r'\n', '\n')
183+
r = r.replace(r'\r', '\r')
184+
return r
185+
174186
if isinstance(left, six.binary_type):
175-
left = u(repr(left)[1:-1]).replace(r'\n', '\n')
187+
left = escape_for_readable_diff(left)
176188
if isinstance(right, six.binary_type):
177-
right = u(repr(right)[1:-1]).replace(r'\n', '\n')
189+
right = escape_for_readable_diff(right)
178190
if not verbose:
179191
i = 0 # just in case left or right has zero length
180192
for i in range(min(len(left), len(right))):
@@ -197,6 +209,10 @@ def _diff_text(left, right, verbose=False):
197209
left = left[:-i]
198210
right = right[:-i]
199211
keepends = True
212+
if left.isspace() or right.isspace():
213+
left = repr(str(left))
214+
right = repr(str(right))
215+
explanation += [u'Strings contain only whitespace, escaping them using repr()']
200216
explanation += [line.strip('\n')
201217
for line in ndiff(left.splitlines(keepends),
202218
right.splitlines(keepends))]

_pytest/capture.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ def disabled(self):
315315

316316

317317
def safe_text_dupfile(f, mode, default_encoding="UTF8"):
318-
""" return a open text file object that's a duplicate of f on the
318+
""" return an open text file object that's a duplicate of f on the
319319
FD-level if possible.
320320
"""
321321
encoding = getattr(f, "encoding", None)

_pytest/compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def safe_getattr(object, name, default):
257257

258258

259259
def _is_unittest_unexpected_success_a_failure():
260-
"""Return if the test suite should fail if a @expectedFailure unittest test PASSES.
260+
"""Return if the test suite should fail if an @expectedFailure unittest test PASSES.
261261
262262
From https://docs.python.org/3/library/unittest.html?highlight=unittest#unittest.TestResult.wasSuccessful:
263263
Changed in version 3.4: Returns False if there were any

_pytest/doctest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
DOCTEST_REPORT_CHOICE_ONLY_FIRST_FAILURE,
2525
)
2626

27-
# Lazy definiton of runner class
27+
# Lazy definition of runner class
2828
RUNNER_CLASS = None
2929

3030

_pytest/fixtures.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def node(self):
291291
def _getnextfixturedef(self, argname):
292292
fixturedefs = self._arg2fixturedefs.get(argname, None)
293293
if fixturedefs is None:
294-
# we arrive here because of a a dynamic call to
294+
# we arrive here because of a dynamic call to
295295
# getfixturevalue(argname) usage which was naturally
296296
# not known at parsing/collection time
297297
parentid = self._pyfuncitem.parent.nodeid
@@ -1028,7 +1028,7 @@ def _getautousenames(self, nodeid):
10281028
def getfixtureclosure(self, fixturenames, parentnode):
10291029
# collect the closure of all fixtures , starting with the given
10301030
# fixturenames as the initial set. As we have to visit all
1031-
# factory definitions anyway, we also return a arg2fixturedefs
1031+
# factory definitions anyway, we also return an arg2fixturedefs
10321032
# mapping so that the caller can reuse it and does not have
10331033
# to re-discover fixturedefs again for each fixturename
10341034
# (discovering matching fixtures for a given name/node is expensive)

_pytest/freeze_support.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
def freeze_includes():
99
"""
10-
Returns a list of module names used by py.test that should be
10+
Returns a list of module names used by pytest that should be
1111
included by cx_freeze.
1212
"""
1313
import py

_pytest/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def pytest_addoption(parser):
9090

9191

9292
def pytest_configure(config):
93-
__import__('pytest').config = config # compatibiltiy
93+
__import__('pytest').config = config # compatibility
9494

9595

9696
def wrap_session(config, doit):
@@ -290,7 +290,7 @@ class Interrupted(KeyboardInterrupt):
290290

291291

292292
class Failed(Exception):
293-
""" signals an stop as failed test run. """
293+
""" signals a stop as failed test run. """
294294

295295

296296
class Session(nodes.FSCollector):

_pytest/mark/structures.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def __call__(self, *args, **kwargs):
215215

216216
def get_unpacked_marks(obj):
217217
"""
218-
obtain the unpacked marks that are stored on a object
218+
obtain the unpacked marks that are stored on an object
219219
"""
220220
mark_list = getattr(obj, 'pytestmark', [])
221221

@@ -228,7 +228,7 @@ def get_unpacked_marks(obj):
228228

229229

230230
def store_mark(obj, mark):
231-
"""store a Mark on a object
231+
"""store a Mark on an object
232232
this is used to implement the Mark declarations/decorators correctly
233233
"""
234234
assert isinstance(mark, Mark), mark

_pytest/outcomes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def skip(msg="", **kwargs):
8383

8484

8585
def fail(msg="", pytrace=True):
86-
""" explicitly fail an currently-executing test with the given Message.
86+
""" explicitly fail a currently-executing test with the given Message.
8787
8888
:arg pytrace: if false the msg represents the full failure information
8989
and no python traceback will be reported.

_pytest/pytester.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ def inline_run(self, *args, **kwargs):
714714
"""
715715
finalizers = []
716716
try:
717-
# When running py.test inline any plugins active in the main test
717+
# When running pytest inline any plugins active in the main test
718718
# process are already imported. So this disables the warning which
719719
# will trigger to say they can no longer be rewritten, which is
720720
# fine as they have already been rewritten.
@@ -725,7 +725,7 @@ def revert_warn_already_imported():
725725
finalizers.append(revert_warn_already_imported)
726726
AssertionRewritingHook._warn_already_imported = lambda *a: None
727727

728-
# Any sys.module or sys.path changes done while running py.test
728+
# Any sys.module or sys.path changes done while running pytest
729729
# inline should be reverted after the test run completes to avoid
730730
# clashing with later inline tests run within the same pytest test,
731731
# e.g. just because they use matching test module names.

_pytest/python.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def filter_traceback(entry):
5555
is_generated = '<' in raw_filename and '>' in raw_filename
5656
if is_generated:
5757
return False
58-
# entry.path might point to an non-existing file, in which case it will
58+
# entry.path might point to a non-existing file, in which case it will
5959
# also return a str object. see #1133
6060
p = py.path.local(entry.path)
6161
return not p.relto(_pluggy_dir) and not p.relto(_pytest_dir) and not p.relto(_py_dir)

changelog/3303.doc.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Change documentation copyright year to a range which auto-updates itself each time it is published.

changelog/3431.trivial.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update all pypi.python.org URLs to pypi.org.

changelog/3443.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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.

doc/en/_templates/links.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<h3>Useful Links</h3>
22
<ul>
3-
<li><a href="https://pypi.python.org/pypi/pytest">pytest @ PyPI</a></li>
3+
<li><a href="https://pypi.org/project/pytest/">pytest @ PyPI</a></li>
44
<li><a href="https://github.com/pytest-dev/pytest/">pytest @ GitHub</a></li>
55
<li><a href="http://plugincompat.herokuapp.com/">3rd party plugins</a></li>
66
<li><a href="https://github.com/pytest-dev/pytest/issues">Issue Tracker</a></li>

doc/en/announce/release-2.3.4.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ comes with the following fixes and features:
1818
rather use the post-2.0 parametrize features instead of yield, see:
1919
http://pytest.org/latest/example/parametrize.html
2020
- fix autouse-issue where autouse-fixtures would not be discovered
21-
if defined in a a/conftest.py file and tests in a/tests/test_some.py
21+
if defined in an a/conftest.py file and tests in a/tests/test_some.py
2222
- fix issue226 - LIFO ordering for fixture teardowns
2323
- fix issue224 - invocations with >256 char arguments now work
2424
- fix issue91 - add/discuss package/directory level setups in example

doc/en/announce/release-2.3.5.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ few interesting new plugins saw the light last month:
1414

1515
And several others like pytest-django saw maintenance releases.
1616
For a more complete list, check out
17-
https://pypi.python.org/pypi?%3Aaction=search&term=pytest&submit=search.
17+
https://pypi.org/search/?q=pytest
1818

1919
For general information see:
2020

doc/en/announce/release-2.4.0.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ a full list of details. A few feature highlights:
2323
called if the corresponding setup method succeeded.
2424

2525
- integrate tab-completion on command line options if you
26-
have `argcomplete <http://pypi.python.org/pypi/argcomplete>`_
26+
have `argcomplete <https://pypi.org/project/argcomplete/>`_
2727
configured.
2828

2929
- allow boolean expression directly with skipif/xfail
3030
if a "reason" is also specified.
3131

3232
- a new hook ``pytest_load_initial_conftests`` allows plugins like
33-
`pytest-django <http://pypi.python.org/pypi/pytest-django>`_ to
33+
`pytest-django <https://pypi.org/project/pytest-django/>`_ to
3434
influence the environment before conftest files import ``django``.
3535

3636
- reporting: color the last line red or green depending if

doc/en/announce/release-2.6.1.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Changes 2.6.1
5252
"::" node id specifications (copy pasted from "-v" output)
5353

5454
- fix issue544 by only removing "@NUM" at the end of "::" separated parts
55-
and if the part has an ".py" extension
55+
and if the part has a ".py" extension
5656

5757
- don't use py.std import helper, rather import things directly.
5858
Thanks Bruno Oliveira.

doc/en/cache.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ Inspecting Cache content
234234
You can always peek at the content of the cache using the
235235
``--cache-show`` command line option::
236236

237-
$ py.test --cache-show
237+
$ pytest --cache-show
238238
=========================== test session starts ============================
239239
platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y
240240
rootdir: $REGENDOC_TMPDIR, inifile:

doc/en/conf.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import os
2222
import sys
23+
import datetime
2324

2425
from _pytest import __version__ as version
2526

@@ -57,7 +58,8 @@
5758

5859
# General information about the project.
5960
project = u'pytest'
60-
copyright = u'2015, holger krekel and pytest-dev team'
61+
year = datetime.datetime.utcnow().year
62+
copyright = u'2015–{} , holger krekel and pytest-dev team'.format(year)
6163

6264

6365

doc/en/development_guide.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Code Style
1010
----------
1111

1212
* `PEP-8 <https://www.python.org/dev/peps/pep-0008>`_
13-
* `flake8 <https://pypi.python.org/pypi/flake8>`_ for quality checks
13+
* `flake8 <https://pypi.org/project/flake8/>`_ for quality checks
1414
* `invoke <http://www.pyinvoke.org/>`_ to automate development tasks
1515

1616

doc/en/example/nonpython.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ A basic example for specifying tests in Yaml files
1010
--------------------------------------------------------------
1111

1212
.. _`pytest-yamlwsgi`: http://bitbucket.org/aafshar/pytest-yamlwsgi/src/tip/pytest_yamlwsgi.py
13-
.. _`PyYAML`: http://pypi.python.org/pypi/PyYAML/
13+
.. _`PyYAML`: https://pypi.org/project/PyYAML/
1414

1515
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:
1616

doc/en/example/parametrize.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ together with the actual data, instead of listing them separately.
160160
A quick port of "testscenarios"
161161
------------------------------------
162162

163-
.. _`test scenarios`: http://pypi.python.org/pypi/testscenarios/
163+
.. _`test scenarios`: https://pypi.org/project/testscenarios/
164164

165165
Here is a quick port to run tests configured with `test scenarios`_,
166166
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::
469469
470470
=================== 1 passed, 1 skipped in 0.12 seconds ====================
471471

472-
You'll see that we don't have a ``opt2`` module and thus the second test run
472+
You'll see that we don't have an ``opt2`` module and thus the second test run
473473
of our ``test_func1`` was skipped. A few notes:
474474

475475
- the fixture functions in the ``conftest.py`` file are "session-scoped" because we

0 commit comments

Comments
 (0)