Skip to content

Commit 08ea620

Browse files
committed
Merge remote-tracking branch 'upstream/master' into mm
Conflicts: src/_pytest/main.py src/_pytest/mark/structures.py src/_pytest/python.py testing/test_main.py testing/test_parseopt.py
2 parents 7484e34 + 0ee007c commit 08ea620

31 files changed

+162
-139
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Here is a quick checklist that should be present in PRs.
77
- [ ] Target the `features` branch for new features, improvements, and removals/deprecations.
88
- [ ] Include documentation when adding new features.
99
- [ ] Include new tests or update existing tests when applicable.
10+
- [X] Allow maintainers to push and squash when merging my commits. Please uncheck this if you prefer to squash the commits yourself.
1011
1112
Unless your change is trivial or a small documentation fix (e.g., a typo or reword of a small section) please:
1213

.travis.yml

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: python
2-
dist: xenial
3-
python: '3.7'
2+
dist: trusty
3+
python: '3.5.1'
44
cache: false
55

66
env:
@@ -16,36 +16,11 @@ install:
1616

1717
jobs:
1818
include:
19-
# OSX tests - first (in test stage), since they are the slower ones.
20-
# Coverage for:
21-
# - osx
22-
# - verbose=1
23-
- os: osx
24-
osx_image: xcode10.1
25-
language: generic
26-
env: TOXENV=py37-xdist PYTEST_COVERAGE=1 PYTEST_ADDOPTS=-v
27-
before_install:
28-
- which python3
29-
- python3 -V
30-
- ln -sfn "$(which python3)" /usr/local/bin/python
31-
- python -V
32-
- test $(python -c 'import sys; print("%d%d" % sys.version_info[0:2])') = 37
33-
34-
# Full run of latest supported version, without xdist.
35-
# Coverage for:
36-
# - pytester's LsofFdLeakChecker
37-
# - TestArgComplete (linux only)
38-
# - numpy
39-
# - old attrs
40-
# - verbose=0
41-
# - test_sys_breakpoint_interception (via pexpect).
42-
- env: TOXENV=py37-lsof-numpy-oldattrs-pexpect-twisted PYTEST_COVERAGE=1 PYTEST_ADDOPTS=
43-
python: '3.7'
44-
4519
# Coverage for Python 3.5.{0,1} specific code, mostly typing related.
4620
- env: TOXENV=py35 PYTEST_COVERAGE=1 PYTEST_ADDOPTS="-k test_raises_cyclic_reference"
47-
python: '3.5.1'
48-
dist: trusty
21+
before_install:
22+
# Work around https://github.com/jaraco/zipp/issues/40.
23+
- python -m pip install -U pip 'setuptools>=34.4.0' virtualenv
4924

5025
before_script:
5126
- |

changelog/6646.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Assertion rewriting hooks are (re)stored for the current item, which fixes them being still used after e.g. pytester's :func:`testdir.runpytest <_pytest.pytester.Testdir.runpytest>` etc.

changelog/6660.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
:func:`pytest.exit() <_pytest.outcomes.exit>` is handled when emitted from the :func:`pytest_sessionfinish <_pytest.hookspec.pytest_sessionfinish>` hook. This includes quitting from a debugger.

doc/en/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
# The name of an image file (within the static path) to use as favicon of the
163163
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
164164
# pixels large.
165-
html_favicon = "img/pytest1favi.ico"
165+
html_favicon = "img/favicon.png"
166166

167167
# Add any paths that contain custom static files (such as style sheets) here,
168168
# relative to this directory. They are copied after the builtin static files,

doc/en/img/favicon.png

1.3 KB
Loading

doc/en/img/pytest1favi.ico

-3.65 KB
Binary file not shown.

doc/en/reference.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -901,8 +901,8 @@ Can be either a ``str`` or ``Sequence[str]``.
901901
pytest_plugins = ("myapp.testsupport.tools", "myapp.testsupport.regression")
902902
903903
904-
pytest_mark
905-
~~~~~~~~~~~
904+
pytestmark
905+
~~~~~~~~~~
906906

907907
**Tutorial**: :ref:`scoped-marking`
908908

src/_pytest/_code/code.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ def path(self) -> Union[py.path.local, str]:
7272
""" return a path object pointing to source code (or a str in case
7373
of OSError / non-existing file).
7474
"""
75+
if not self.raw.co_filename:
76+
return ""
7577
try:
7678
p = py.path.local(self.raw.co_filename)
7779
# maybe don't try this checking

src/_pytest/_code/source.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from bisect import bisect_right
99
from types import CodeType
1010
from types import FrameType
11+
from typing import Any
1112
from typing import Iterator
1213
from typing import List
1314
from typing import Optional
@@ -17,6 +18,7 @@
1718

1819
import py
1920

21+
from _pytest.compat import get_real_func
2022
from _pytest.compat import overload
2123
from _pytest.compat import TYPE_CHECKING
2224

@@ -277,14 +279,21 @@ def compile_( # noqa: F811
277279
return s.compile(filename, mode, flags, _genframe=_genframe)
278280

279281

280-
def getfslineno(obj) -> Tuple[Optional[Union["Literal['']", py.path.local]], int]:
282+
def getfslineno(obj: Any) -> Tuple[Union[str, py.path.local], int]:
281283
""" Return source location (path, lineno) for the given object.
282284
If the source cannot be determined return ("", -1).
283285
284286
The line number is 0-based.
285287
"""
286288
from .code import Code
287289

290+
# xxx let decorators etc specify a sane ordering
291+
# NOTE: this used to be done in _pytest.compat.getfslineno, initially added
292+
# in 6ec13a2b9. It ("place_as") appears to be something very custom.
293+
obj = get_real_func(obj)
294+
if hasattr(obj, "place_as"):
295+
obj = obj.place_as
296+
288297
try:
289298
code = Code(obj)
290299
except TypeError:
@@ -293,18 +302,16 @@ def getfslineno(obj) -> Tuple[Optional[Union["Literal['']", py.path.local]], int
293302
except TypeError:
294303
return "", -1
295304

296-
fspath = fn and py.path.local(fn) or None
305+
fspath = fn and py.path.local(fn) or ""
297306
lineno = -1
298307
if fspath:
299308
try:
300309
_, lineno = findsource(obj)
301310
except IOError:
302311
pass
312+
return fspath, lineno
303313
else:
304-
fspath = code.path
305-
lineno = code.firstlineno
306-
assert isinstance(lineno, int)
307-
return fspath, lineno
314+
return code.path, code.firstlineno
308315

309316

310317
#

0 commit comments

Comments
 (0)