Skip to content

Commit 293351c

Browse files
authored
Merge pull request #1705 from RonnyPfannschmidt/merge-master
Merge from master to features
2 parents f31c31a + dad6aa8 commit 293351c

25 files changed

+198
-208
lines changed

CHANGELOG.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,36 @@
172172
* Add proposal to docs for a new feature that enables users to combine multiple
173173
fixtures into one. Thanks to `@hpk42`_ and `@hackebrot`_.
174174

175+
* Rename ``getfuncargvalue`` to ``getfixturevalue``. ``getfuncargvalue`` is
176+
deprecated but still present. Thanks to `@RedBeardCode`_ and `@tomviner`_
177+
for PR (`#1626`_).
178+
179+
* Always include full assertion explanation. The previous behaviour was hiding
180+
sub-expressions that happened to be False, assuming this was redundant information.
181+
Thanks `@bagerard`_ for reporting (`#1503`_). Thanks to `@davehunt`_ and
182+
`@tomviner`_ for PR.
183+
184+
* Renamed the pytest ``pdb`` module (plugin) into ``debugging``.
185+
186+
* Improve of the test output for logical expression with brackets.
187+
Fixes(`#925`_). Thanks `@DRMacIver`_ for reporting. Thanks to `@RedBeardCode`_
188+
for PR.
189+
190+
* ImportErrors in plugins now are a fatal error instead of issuing a
175191

176192
.. _#1632: https://github.com/pytest-dev/pytest/issues/1632
193+
194+
pytest warning (`#1479`_). Thanks to `@The-Compiler`_ for the PR.
195+
177196
.. _#1580: https://github.com/pytest-dev/pytest/pull/1580
178197
.. _#1605: https://github.com/pytest-dev/pytest/issues/1605
179198
.. _#1597: https://github.com/pytest-dev/pytest/pull/1597
180199
.. _#460: https://github.com/pytest-dev/pytest/pull/460
181200
.. _#1553: https://github.com/pytest-dev/pytest/issues/1553
201+
.. _#1626: https://github.com/pytest-dev/pytest/pull/1626
202+
.. _#1503: https://github.com/pytest-dev/pytest/issues/1503
203+
.. _#1479: https://github.com/pytest-dev/pytest/issues/1479
204+
.. _#925: https://github.com/pytest-dev/pytest/issues/925
182205

183206
.. _@graingert: https://github.com/graingert
184207
.. _@taschini: https://github.com/taschini
@@ -187,6 +210,8 @@
187210
.. _@Vogtinator: https://github.com/Vogtinator
188211
.. _@blueyed: https://github.com/blueyed
189212
.. _@fengxx: https://github.com/fengxx
213+
.. _@bagerard: https://github.com/bagerard
214+
.. _@DRMacIver: https://github.com/DRMacIver
190215

191216
* Fix `#1421`_: Exit tests if a collection error occurs and add
192217
``--continue-on-collection-errors`` option to restore previous behaviour.

CONTRIBUTING.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ the following:
120120

121121
- an issue tracker for bug reports and enhancement requests.
122122

123+
- a `changelog <http://keepachangelog.com/>`_
124+
123125
If no contributor strongly objects and two agree, the repository can then be
124126
transferred to the ``pytest-dev`` organisation.
125127

_pytest/assertion/rewrite.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Rewrite assertion AST to produce nice error messages"""
22

33
import ast
4+
import _ast
45
import errno
56
import itertools
67
import imp
@@ -876,6 +877,8 @@ def visit_Attribute(self, attr):
876877
def visit_Compare(self, comp):
877878
self.push_format_context()
878879
left_res, left_expl = self.visit(comp.left)
880+
if isinstance(comp.left, (_ast.Compare, _ast.BoolOp)):
881+
left_expl = "({0})".format(left_expl)
879882
res_variables = [self.variable() for i in range(len(comp.ops))]
880883
load_names = [ast.Name(v, ast.Load()) for v in res_variables]
881884
store_names = [ast.Name(v, ast.Store()) for v in res_variables]
@@ -885,6 +888,8 @@ def visit_Compare(self, comp):
885888
results = [left_res]
886889
for i, op, next_operand in it:
887890
next_res, next_expl = self.visit(next_operand)
891+
if isinstance(next_operand, (_ast.Compare, _ast.BoolOp)):
892+
next_expl = "({0})".format(next_expl)
888893
results.append(next_res)
889894
sym = binop_map[op.__class__]
890895
syms.append(ast.Str(sym))

_pytest/assertion/util.py

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -38,44 +38,11 @@ def format_explanation(explanation):
3838
displaying diffs.
3939
"""
4040
explanation = ecu(explanation)
41-
explanation = _collapse_false(explanation)
4241
lines = _split_explanation(explanation)
4342
result = _format_lines(lines)
4443
return u('\n').join(result)
4544

4645

47-
def _collapse_false(explanation):
48-
"""Collapse expansions of False
49-
50-
So this strips out any "assert False\n{where False = ...\n}"
51-
blocks.
52-
"""
53-
where = 0
54-
while True:
55-
start = where = explanation.find("False\n{False = ", where)
56-
if where == -1:
57-
break
58-
level = 0
59-
prev_c = explanation[start]
60-
for i, c in enumerate(explanation[start:]):
61-
if prev_c + c == "\n{":
62-
level += 1
63-
elif prev_c + c == "\n}":
64-
level -= 1
65-
if not level:
66-
break
67-
prev_c = c
68-
else:
69-
raise AssertionError("unbalanced braces: %r" % (explanation,))
70-
end = start + i
71-
where = end
72-
if explanation[end - 1] == '\n':
73-
explanation = (explanation[:start] + explanation[start+15:end-1] +
74-
explanation[end+1:])
75-
where -= 17
76-
return explanation
77-
78-
7946
def _split_explanation(explanation):
8047
"""Return a list of individual lines in the explanation
8148

_pytest/config.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class UsageError(Exception):
6363
_preinit = []
6464

6565
default_plugins = (
66-
"mark main terminal runner python pdb unittest capture skipping "
66+
"mark main terminal runner python debugging unittest capture skipping "
6767
"tmpdir monkeypatch recwarn pastebin helpconfig nose assertion "
6868
"junitxml resultlog doctest cacheprovider freeze_support "
6969
"setuponly setupplan").split()
@@ -656,20 +656,17 @@ def _set_opt_strings(self, opts):
656656
self._long_opts.append(opt)
657657

658658
def __repr__(self):
659-
retval = 'Argument('
659+
args = []
660660
if self._short_opts:
661-
retval += '_short_opts: ' + repr(self._short_opts) + ', '
661+
args += ['_short_opts: ' + repr(self._short_opts)]
662662
if self._long_opts:
663-
retval += '_long_opts: ' + repr(self._long_opts) + ', '
664-
retval += 'dest: ' + repr(self.dest) + ', '
663+
args += ['_long_opts: ' + repr(self._long_opts)]
664+
args += ['dest: ' + repr(self.dest)]
665665
if hasattr(self, 'type'):
666-
retval += 'type: ' + repr(self.type) + ', '
666+
args += ['type: ' + repr(self.type)]
667667
if hasattr(self, 'default'):
668-
retval += 'default: ' + repr(self.default) + ', '
669-
if retval[-2:] == ', ': # always long enough to test ("Argument(" )
670-
retval = retval[:-2]
671-
retval += ')'
672-
return retval
668+
args += ['default: ' + repr(self.default)]
669+
return 'Argument({0})'.format(', '.join(args))
673670

674671

675672
class OptionGroup:
@@ -928,10 +925,7 @@ def _preparse(self, args, addopts=True):
928925
args[:] = self.getini("addopts") + args
929926
self._checkversion()
930927
self.pluginmanager.consider_preparse(args)
931-
try:
932-
self.pluginmanager.load_setuptools_entrypoints("pytest11")
933-
except ImportError as e:
934-
self.warn("I2", "could not load setuptools entry import: %s" % (e,))
928+
self.pluginmanager.load_setuptools_entrypoints("pytest11")
935929
self.pluginmanager.consider_env()
936930
self.known_args_namespace = ns = self._parser.parse_known_args(args, namespace=self.option.copy())
937931
if self.known_args_namespace.confcutdir is None and self.inifile:
File renamed without changes.

_pytest/doctest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def __init__(self, name, parent, runner=None, dtest=None):
7070
def setup(self):
7171
if self.dtest is not None:
7272
self.fixture_request = _setup_fixtures(self)
73-
globs = dict(getfixture=self.fixture_request.getfuncargvalue)
73+
globs = dict(getfixture=self.fixture_request.getfixturevalue)
7474
for name, value in self.fixture_request.getfuncargvalue('doctest_namespace').items():
7575
globs[name] = value
7676
self.dtest.globs.update(globs)

_pytest/python.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
import re
77
import types
88
import sys
9-
import math
9+
import warnings
1010
import collections
11+
import math
1112

1213
import py
1314
import pytest
@@ -1855,7 +1856,7 @@ def _getnextfixturedef(self, argname):
18551856
fixturedefs = self._arg2fixturedefs.get(argname, None)
18561857
if fixturedefs is None:
18571858
# we arrive here because of a a dynamic call to
1858-
# getfuncargvalue(argname) usage which was naturally
1859+
# getfixturevalue(argname) usage which was naturally
18591860
# not known at parsing/collection time
18601861
fixturedefs = self._fixturemanager.getfixturedefs(
18611862
argname, self._pyfuncitem.parent.nodeid)
@@ -1950,7 +1951,7 @@ def _fillfixtures(self):
19501951
fixturenames = getattr(item, "fixturenames", self.fixturenames)
19511952
for argname in fixturenames:
19521953
if argname not in item.funcargs:
1953-
item.funcargs[argname] = self.getfuncargvalue(argname)
1954+
item.funcargs[argname] = self.getfixturevalue(argname)
19541955

19551956
def cached_setup(self, setup, teardown=None, scope="module", extrakey=None):
19561957
""" (deprecated) Return a testing resource managed by ``setup`` &
@@ -1984,17 +1985,23 @@ def finalizer():
19841985
self._addfinalizer(finalizer, scope=scope)
19851986
return val
19861987

1987-
def getfuncargvalue(self, argname):
1988-
""" Dynamically retrieve a named fixture function argument.
1988+
def getfixturevalue(self, argname):
1989+
""" Dynamically run a named fixture function.
19891990
1990-
As of pytest-2.3, it is easier and usually better to access other
1991-
fixture values by stating it as an input argument in the fixture
1992-
function. If you only can decide about using another fixture at test
1991+
Declaring fixtures via function argument is recommended where possible.
1992+
But if you can only decide whether to use another fixture at test
19931993
setup time, you may use this function to retrieve it inside a fixture
1994-
function body.
1994+
or test function body.
19951995
"""
19961996
return self._get_active_fixturedef(argname).cached_result[0]
19971997

1998+
def getfuncargvalue(self, argname):
1999+
""" Deprecated, use getfixturevalue. """
2000+
warnings.warn(
2001+
"use of getfuncargvalue is deprecated, use getfixturevalue",
2002+
DeprecationWarning)
2003+
return self.getfixturevalue(argname)
2004+
19982005
def _get_active_fixturedef(self, argname):
19992006
try:
20002007
return self._fixturedefs[argname]
@@ -2010,7 +2017,7 @@ class PseudoFixtureDef:
20102017
raise
20112018
# remove indent to prevent the python3 exception
20122019
# from leaking into the call
2013-
result = self._getfuncargvalue(fixturedef)
2020+
result = self._getfixturevalue(fixturedef)
20142021
self._funcargs[argname] = result
20152022
self._fixturedefs[argname] = fixturedef
20162023
return fixturedef
@@ -2026,7 +2033,7 @@ def _get_fixturestack(self):
20262033
l.append(fixturedef)
20272034
current = current._parent_request
20282035

2029-
def _getfuncargvalue(self, fixturedef):
2036+
def _getfixturevalue(self, fixturedef):
20302037
# prepare a subrequest object before calling fixture function
20312038
# (latter managed by fixturedef)
20322039
argname = fixturedef.argname

appveyor.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ environment:
55
# using pytestbot account as detailed here:
66
# https://www.appveyor.com/docs/build-configuration#secure-variables
77

8+
matrix:
9+
# create multiple jobs to execute a set of tox runs on each; this is to workaround having
10+
# builds timing out in AppVeyor
11+
- TOXENV: "linting,py26,py27,py33,py34,py35,pypy"
12+
- TOXENV: "py27-pexpect,py27-xdist,py27-trial,py35-pexpect,py35-xdist,py35-trial"
13+
- TOXENV: "py27-nobyte,doctesting,py27-cxfreeze"
14+
815
install:
916
- echo Installed Pythons
1017
- dir c:\Python*

doc/en/_templates/layout.html

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,5 @@
11
{% extends "!layout.html" %}
22
{% block header %}
3-
<div align="center" xmlns="http://www.w3.org/1999/html" style="background-color: lightgreen; padding: .5em">
4-
<h4>
5-
Want to help improve pytest? Please
6-
<a href="https://www.indiegogo.com/projects/python-testing-sprint-mid-2016#/">
7-
contribute to
8-
</a>
9-
or
10-
<a href="announce/sprint2016.html">
11-
join
12-
</a>
13-
our upcoming sprint in June 2016!
14-
15-
</h4>
16-
</div>
173
{{super()}}
184
{% endblock %}
195
{% block footer %}

doc/en/_templates/links.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
<h3>Useful Links</h3>
22
<ul>
3-
<li>
4-
<a href="https://www.indiegogo.com/projects/python-testing-sprint-mid-2016#/">
5-
<b>Sprint funding campaign</b>
6-
</a>
7-
</li>
83
<li><a href="{{ pathto('index') }}">The pytest Website</a></li>
94
<li><a href="{{ pathto('contributing') }}">Contribution Guide</a></li>
105
<li><a href="https://pypi.python.org/pypi/pytest">pytest @ PyPI</a></li>

0 commit comments

Comments
 (0)