Skip to content

Commit 10d27f4

Browse files
Merge pull request #4360 from blueyed/merge-master
Merge master into features
2 parents b92530d + 1b260a8 commit 10d27f4

File tree

16 files changed

+58
-23
lines changed

16 files changed

+58
-23
lines changed

.travis.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ jobs:
4747
env: TOXENV=py37
4848
before_install:
4949
- brew update
50-
# remove c++ include files because upgrading python as of 2018-10-23, also
51-
# attempts to upgrade gcc, and it fails because the include files already
52-
# exist. removing the include files is one of the solutions recommended by brew
53-
# this workaround might not be necessary in the future
54-
- rm '/usr/local/include/c++'
5550
- brew upgrade python
5651
- brew unlink python
5752
- brew link python

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ Endre Galaczi
7676
Eric Hunsberger
7777
Eric Siegerman
7878
Erik M. Bray
79+
Fabien Zarifian
7980
Fabio Zadrozny
8081
Feng Ma
8182
Florian Bruhin

changelog/4304.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Block the ``stepwise`` plugin if ``cacheprovider`` is also blocked, as one depends on the other.

changelog/4329.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix TypeError in report_collect with _collect_report_last_write.

doc/en/usage.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ Pytest supports the use of ``breakpoint()`` with the following behaviours:
255255

256256
- When ``breakpoint()`` is called and ``PYTHONBREAKPOINT`` is set to the default value, pytest will use the custom internal PDB trace UI instead of the system default ``Pdb``.
257257
- When tests are complete, the system will default back to the system ``Pdb`` trace UI.
258-
- If ``--pdb`` is called on execution of pytest, the custom internal Pdb trace UI is used on both ``breakpoint()`` and failed tests/unhandled exceptions.
259-
- If ``--pdbcls`` is used, the custom class debugger will be executed when a test fails (as expected within existing behaviour), but also when ``breakpoint()`` is called from within a test, the custom class debugger will be instantiated.
258+
- With ``--pdb`` passed to pytest, the custom internal Pdb trace UI is used with both ``breakpoint()`` and failed tests/unhandled exceptions.
259+
- ``--pdbcls`` can be used to specify a custom debugger class.
260260

261261
.. _durations:
262262

src/_pytest/config/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,11 @@ def consider_preparse(self, args):
477477
def consider_pluginarg(self, arg):
478478
if arg.startswith("no:"):
479479
name = arg[3:]
480+
# PR #4304 : remove stepwise if cacheprovider is blocked
481+
if name == "cacheprovider":
482+
self.set_blocked("stepwise")
483+
self.set_blocked("pytest_stepwise")
484+
480485
self.set_blocked(name)
481486
if not name.startswith("pytest_"):
482487
self.set_blocked("pytest_" + name)

src/_pytest/fixtures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ def execute(self, request):
927927
return hook.pytest_fixture_setup(fixturedef=self, request=request)
928928

929929
def __repr__(self):
930-
return "<FixtureDef name=%r scope=%r baseid=%r>" % (
930+
return "<FixtureDef argname=%r scope=%r baseid=%r>" % (
931931
self.argname,
932932
self.scope,
933933
self.baseid,

src/_pytest/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ def pytest_ignore_collect(path, config):
279279
return True
280280

281281
allow_in_venv = config.getoption("collect_in_virtualenv")
282-
if _in_venv(path) and not allow_in_venv:
282+
if not allow_in_venv and _in_venv(path):
283283
return True
284284

285285
return False
@@ -511,9 +511,9 @@ def _collect(self, arg):
511511
# No point in finding packages when collecting doctests
512512
if not self.config.option.doctestmodules:
513513
pm = self.config.pluginmanager
514-
for parent in argpath.parts():
514+
for parent in reversed(argpath.parts()):
515515
if pm._confcutdir and pm._confcutdir.relto(parent):
516-
continue
516+
break
517517

518518
if parent.isdir():
519519
pkginit = parent.join("__init__.py")

src/_pytest/pytester.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,11 +1160,11 @@ def runpython_c(self, command):
11601160
def runpytest_subprocess(self, *args, **kwargs):
11611161
"""Run pytest as a subprocess with given arguments.
11621162
1163-
Any plugins added to the :py:attr:`plugins` list will added using the
1164-
``-p`` command line option. Additionally ``--basetemp`` is used put
1163+
Any plugins added to the :py:attr:`plugins` list will be added using the
1164+
``-p`` command line option. Additionally ``--basetemp`` is used to put
11651165
any temporary files and directories in a numbered directory prefixed
1166-
with "runpytest-" so they do not conflict with the normal numbered
1167-
pytest location for temporary files and directories.
1166+
with "runpytest-" to not conflict with the normal numbered pytest
1167+
location for temporary files and directories.
11681168
11691169
:param args: the sequence of arguments to pass to the pytest subprocess
11701170
:param timeout: the period in seconds after which to timeout and raise

src/_pytest/terminal.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,10 @@ def report_collect(self, final=False):
497497
if not final:
498498
# Only write "collecting" report every 0.5s.
499499
t = time.time()
500-
if self._collect_report_last_write > t - 0.5:
500+
if (
501+
self._collect_report_last_write is not None
502+
and self._collect_report_last_write > t - 0.5
503+
):
501504
return
502505
self._collect_report_last_write = t
503506

testing/acceptance_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ class TestGeneralUsage(object):
2727
def test_config_error(self, testdir):
2828
testdir.copy_example("conftest_usageerror/conftest.py")
2929
result = testdir.runpytest(testdir.tmpdir)
30-
assert result.ret != 0
30+
assert result.ret == EXIT_USAGEERROR
3131
result.stderr.fnmatch_lines(["*ERROR: hello"])
32+
result.stdout.fnmatch_lines(["*pytest_unconfigure_called"])
3233

3334
def test_root_conftest_syntax_error(self, testdir):
3435
testdir.makepyfile(conftest="raise SyntaxError\n")

testing/example_scripts/conftest_usageerror/conftest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@ def pytest_configure(config):
22
import pytest
33

44
raise pytest.UsageError("hello")
5+
6+
7+
def pytest_unconfigure(config):
8+
print("pytest_unconfigure_called")

testing/logging/test_fixture.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,5 +136,5 @@ def test_caplog_captures_for_all_stages(caplog, logging_during_setup_and_teardow
136136

137137
assert [x.message for x in caplog.get_records("setup")] == ["a_setup_log"]
138138

139-
# This reachers into private API, don't use this type of thing in real tests!
139+
# This reaches into private API, don't use this type of thing in real tests!
140140
assert set(caplog._item.catch_log_handlers.keys()) == {"setup", "call"}

testing/test_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ def test_with_ini(self, tmpdir, name):
874874
assert inifile == inifile
875875

876876
@pytest.mark.parametrize("name", "setup.cfg tox.ini".split())
877-
def test_pytestini_overides_empty_other(self, tmpdir, name):
877+
def test_pytestini_overrides_empty_other(self, tmpdir, name):
878878
inifile = tmpdir.ensure("pytest.ini")
879879
a = tmpdir.mkdir("a")
880880
a.ensure(name)

testing/test_modimport.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,19 @@ def test_fileimport(modfile):
1919
# without needing the pytest namespace being set
2020
# this is critical for the initialization of xdist
2121

22-
res = subprocess.call(
22+
p = subprocess.Popen(
2323
[
2424
sys.executable,
2525
"-c",
2626
"import sys, py; py.path.local(sys.argv[1]).pyimport()",
2727
modfile.strpath,
28-
]
28+
],
29+
stdout=subprocess.PIPE,
30+
stderr=subprocess.PIPE,
2931
)
30-
if res:
31-
pytest.fail("command result %s" % res)
32+
(out, err) = p.communicate()
33+
if p.returncode != 0:
34+
pytest.fail(
35+
"importing %s failed (exitcode %d): out=%r, err=%r"
36+
% (modfile, p.returncode, out, err)
37+
)

testing/test_pluginmanager.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,3 +380,21 @@ def test_plugin_prevent_register_unregistered_alredy_registered(self, pytestpm):
380380
pytestpm.consider_preparse(["xyz", "-p", "no:abc"])
381381
l2 = pytestpm.get_plugins()
382382
assert 42 not in l2
383+
384+
def test_plugin_prevent_register_stepwise_on_cacheprovider_unregister(
385+
self, pytestpm
386+
):
387+
""" From PR #4304 : The only way to unregister a module is documented at
388+
the end of https://docs.pytest.org/en/latest/plugins.html.
389+
390+
When unregister cacheprovider, then unregister stepwise too
391+
"""
392+
pytestpm.register(42, name="cacheprovider")
393+
pytestpm.register(43, name="stepwise")
394+
l1 = pytestpm.get_plugins()
395+
assert 42 in l1
396+
assert 43 in l1
397+
pytestpm.consider_preparse(["xyz", "-p", "no:cacheprovider"])
398+
l2 = pytestpm.get_plugins()
399+
assert 42 not in l2
400+
assert 43 not in l2

0 commit comments

Comments
 (0)