Skip to content

Commit 7d923c3

Browse files
turturicaturturica
turturica
authored and
turturica
committed
Merge remote-tracking branch 'upstream/features' into features
2 parents c02e8d8 + 13a6f63 commit 7d923c3

Some content is hidden

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

61 files changed

+130
-159
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ Tareq Alayan
191191
Ted Xiao
192192
Thomas Grainger
193193
Thomas Hisch
194+
Tim Strazny
194195
Tom Dalton
195196
Tom Viner
196197
Trevor Bekolay

CHANGELOG.rst

Lines changed: 1 addition & 1 deletion

_pytest/assertion/rewrite.py

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
import sys
1313
import types
1414

15+
import atomicwrites
1516
import py
17+
1618
from _pytest.assertion import util
1719

1820

@@ -140,7 +142,7 @@ def find_module(self, name, path=None):
140142
# Probably a SyntaxError in the test.
141143
return None
142144
if write:
143-
_make_rewritten_pyc(state, source_stat, pyc, co)
145+
_write_pyc(state, co, source_stat, pyc)
144146
else:
145147
state.trace("found cached rewritten pyc for %r" % (fn,))
146148
self.modules[name] = co, pyc
@@ -258,22 +260,21 @@ def _write_pyc(state, co, source_stat, pyc):
258260
# sometime to be able to use imp.load_compiled to load them. (See
259261
# the comment in load_module above.)
260262
try:
261-
fp = open(pyc, "wb")
262-
except IOError:
263-
err = sys.exc_info()[1].errno
264-
state.trace("error writing pyc file at %s: errno=%s" % (pyc, err))
263+
with atomicwrites.atomic_write(pyc, mode="wb", overwrite=True) as fp:
264+
fp.write(imp.get_magic())
265+
mtime = int(source_stat.mtime)
266+
size = source_stat.size & 0xFFFFFFFF
267+
fp.write(struct.pack("<ll", mtime, size))
268+
if six.PY2:
269+
marshal.dump(co, fp.file)
270+
else:
271+
marshal.dump(co, fp)
272+
except EnvironmentError as e:
273+
state.trace("error writing pyc file at %s: errno=%s" % (pyc, e.errno))
265274
# we ignore any failure to write the cache file
266275
# there are many reasons, permission-denied, __pycache__ being a
267276
# file etc.
268277
return False
269-
try:
270-
fp.write(imp.get_magic())
271-
mtime = int(source_stat.mtime)
272-
size = source_stat.size & 0xFFFFFFFF
273-
fp.write(struct.pack("<ll", mtime, size))
274-
marshal.dump(co, fp)
275-
finally:
276-
fp.close()
277278
return True
278279

279280

@@ -338,20 +339,6 @@ def _rewrite_test(config, fn):
338339
return stat, co
339340

340341

341-
def _make_rewritten_pyc(state, source_stat, pyc, co):
342-
"""Try to dump rewritten code to *pyc*."""
343-
if sys.platform.startswith("win"):
344-
# Windows grants exclusive access to open files and doesn't have atomic
345-
# rename, so just write into the final file.
346-
_write_pyc(state, co, source_stat, pyc)
347-
else:
348-
# When not on windows, assume rename is atomic. Dump the code object
349-
# into a file specific to this process and atomically replace it.
350-
proc_pyc = pyc + "." + str(os.getpid())
351-
if _write_pyc(state, co, source_stat, proc_pyc):
352-
os.rename(proc_pyc, pyc)
353-
354-
355342
def _read_pyc(source, pyc, trace=lambda x: None):
356343
"""Possibly read a pytest pyc containing rewritten code.
357344

_pytest/assertion/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import _pytest._code
66
import py
77
import six
8-
from collections import Sequence
8+
from ..compat import Sequence
99

1010
u = six.text_type
1111

_pytest/compat.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@
3838
PY36 = sys.version_info[:2] >= (3, 6)
3939
MODULE_NOT_FOUND_ERROR = 'ModuleNotFoundError' if PY36 else 'ImportError'
4040

41+
if _PY3:
42+
from collections.abc import MutableMapping as MappingMixin # noqa
43+
from collections.abc import Sequence # noqa
44+
else:
45+
# those raise DeprecationWarnings in Python >=3.7
46+
from collections import MutableMapping as MappingMixin # noqa
47+
from collections import Sequence # noqa
48+
4149

4250
def _format_args(func):
4351
return str(signature(func))

_pytest/hookspec.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,14 +413,15 @@ def pytest_fixture_post_finalizer(fixturedef, request):
413413

414414

415415
def pytest_sessionstart(session):
416-
""" before session.main() is called.
416+
""" called after the ``Session`` object has been created and before performing collection
417+
and entering the run test loop.
417418
418419
:param _pytest.main.Session session: the pytest session object
419420
"""
420421

421422

422423
def pytest_sessionfinish(session, exitstatus):
423-
""" whole test run finishes.
424+
""" called after whole test run finished, right before returning the exit status to the system.
424425
425426
:param _pytest.main.Session session: the pytest session object
426427
:param int exitstatus: the status which pytest will return to the system

_pytest/junitxml.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,6 @@ def record_property(request):
245245
def test_function(record_property):
246246
record_property("example_key", 1)
247247
"""
248-
request.node.warn(
249-
code='C3',
250-
message='record_property is an experimental feature',
251-
)
252-
253248
def append_property(name, value):
254249
request.node.user_properties.append((name, value))
255250
return append_property

_pytest/mark/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ class MarkerError(Exception):
2020

2121

2222
def param(*values, **kw):
23-
"""Specify a parameter in a `pytest.mark.parametrize`_ call.
23+
"""Specify a parameter in `pytest.mark.parametrize`_ calls or
24+
:ref:`parametrized fixtures <fixture-parametrize-marks>`.
2425
2526
.. code-block:: python
2627

_pytest/mark/structures.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
from collections import namedtuple, MutableMapping as MappingMixin
1+
import inspect
22
import warnings
3+
from collections import namedtuple
34
from operator import attrgetter
4-
import inspect
55

66
import attr
77

88
from ..deprecated import MARK_PARAMETERSET_UNPACKING, MARK_INFO_ATTRIBUTE
9-
from ..compat import NOTSET, getfslineno
9+
from ..compat import NOTSET, getfslineno, MappingMixin
1010
from six.moves import map, reduce
1111

1212

_pytest/python_api.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import sys
33

44
import py
5+
from six import binary_type, text_type
56
from six.moves import zip, filterfalse
67
from more_itertools.more import always_iterable
78

@@ -584,7 +585,8 @@ def raises(expected_exception, *args, **kwargs):
584585
585586
"""
586587
__tracebackhide__ = True
587-
for exc in filterfalse(isclass, always_iterable(expected_exception)):
588+
base_type = (type, text_type, binary_type)
589+
for exc in filterfalse(isclass, always_iterable(expected_exception, base_type)):
588590
msg = ("exceptions must be old-style classes or"
589591
" derived from BaseException, not %s")
590592
raise TypeError(msg % type(exc))
@@ -597,6 +599,10 @@ def raises(expected_exception, *args, **kwargs):
597599
message = kwargs.pop("message")
598600
if "match" in kwargs:
599601
match_expr = kwargs.pop("match")
602+
if kwargs:
603+
msg = 'Unexpected keyword arguments passed to pytest.raises: '
604+
msg += ', '.join(kwargs.keys())
605+
raise TypeError(msg)
600606
return RaisesContext(expected_exception, message, match_expr)
601607
elif isinstance(args[0], str):
602608
code, = args

changelog/1478.feature

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/1642.feature.rst

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/1713.doc.rst

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/2370.bugfix.rst

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/2405.feature.rst

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/2770.feature

Lines changed: 0 additions & 2 deletions
This file was deleted.

changelog/2770.removal.rst

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/3008.bugfix.rst

Lines changed: 1 addition & 0 deletions

changelog/3008.trivial.rst

Lines changed: 1 addition & 0 deletions

changelog/3034.feature

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/3084.removal

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/3139.feature

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/3149.feature

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/3156.feature

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/3189.feature

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/3190.feature

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/3198.feature.rst

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/3204.feature

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/3213.feature

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/3228.trivial.rst

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/3236.feature.rst

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/3245.trivial.rst

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/3246.trival.rst

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/3250.trivial.rst

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/3255.feature.rst

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/3265.trivial.rst

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/3268.trivial

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/3291.trivial.rst

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/3292.trivial.rst

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/3296.feature

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/3296.trivial

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/3297.bugfix.rst

Lines changed: 0 additions & 2 deletions
This file was deleted.

changelog/3304.trivial

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/3308.trivial.rst

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/3312.feature

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/3314.bugfix.rst

Lines changed: 0 additions & 3 deletions
This file was deleted.

changelog/3339.trivial

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Import some modules from ``collections`` instead of ``collections.abc`` as the former modules trigger ``DeprecationWarning`` in Python 3.7.

changelog/3348.bugfix.rst

Lines changed: 1 addition & 0 deletions

changelog/3360.trivial

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
record_property is no longer experimental, removing the warnings was forgotten.
2+

changelog/3372.bugfix.rst

Lines changed: 1 addition & 0 deletions

doc/en/development_guide.rst

Lines changed: 9 additions & 62 deletions

doc/en/example/reportingdemo.rst

Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)