Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
c55ca15
Update __init__.py
fzarifian Nov 4, 2018
a447dc8
Add test to branch
fzarifian Nov 4, 2018
1793ac3
Update __init__.py
fzarifian Nov 4, 2018
db70c75
Create 4304.bugfix.rst
fzarifian Nov 4, 2018
5f61f0d
Update __init__.py
fzarifian Nov 5, 2018
9a884f1
Improve changelog a bit
nicoddemus Nov 7, 2018
17b8e2d
Fix linting
nicoddemus Nov 7, 2018
91404db
Fix TypeError in report_collect with _collect_report_last_write
blueyed Nov 7, 2018
f48a26f
Update AUTHORS
fzarifian Nov 8, 2018
f06fe43
Merge pull request #4330 from blueyed/fix-report-last-write
blueyed Nov 8, 2018
423e199
Merge pull request #4307 from fzarifian/fzarifian-pr4304
nicoddemus Nov 8, 2018
bb8a849
Revert "Attempt to fix macosx build setup"
blueyed Nov 8, 2018
b494d3d
tests: test_fileimport: improve reporting on failure
blueyed Nov 9, 2018
401a3cd
minor: improve FixtureDef.__repr__
blueyed Nov 9, 2018
a0890f9
tests: harden test_config_error
blueyed Nov 9, 2018
560c055
Session._collect: use reversed parts
blueyed Nov 9, 2018
c1bde8e
minor: check bool before function call
blueyed Nov 9, 2018
4a74d45
minor: typos
blueyed Nov 9, 2018
859b322
doc: improve/simplify doc for breakpoint behavior
blueyed Nov 9, 2018
feccf53
doc: improve runpytest_subprocess
blueyed Nov 9, 2018
d4fdf79
Merge pull request #4350 from blueyed/fix-macos-py37
blueyed Nov 9, 2018
afaad2f
Merge pull request #4354 from blueyed/minor
blueyed Nov 9, 2018
e00f3a2
Merge pull request #4353 from blueyed/test_fileimport
nicoddemus Nov 9, 2018
1b260a8
Merge branch 'master' into features
blueyed Nov 9, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ jobs:
env: TOXENV=py37
before_install:
- brew update
# remove c++ include files because upgrading python as of 2018-10-23, also
# attempts to upgrade gcc, and it fails because the include files already
# exist. removing the include files is one of the solutions recommended by brew
# this workaround might not be necessary in the future
- rm '/usr/local/include/c++'
- brew upgrade python
- brew unlink python
- brew link python
Expand Down
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Endre Galaczi
Eric Hunsberger
Eric Siegerman
Erik M. Bray
Fabien Zarifian
Fabio Zadrozny
Feng Ma
Florian Bruhin
Expand Down
1 change: 1 addition & 0 deletions changelog/4304.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Block the ``stepwise`` plugin if ``cacheprovider`` is also blocked, as one depends on the other.
1 change: 1 addition & 0 deletions changelog/4329.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix TypeError in report_collect with _collect_report_last_write.
4 changes: 2 additions & 2 deletions doc/en/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ Pytest supports the use of ``breakpoint()`` with the following behaviours:

- 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``.
- When tests are complete, the system will default back to the system ``Pdb`` trace UI.
- If ``--pdb`` is called on execution of pytest, the custom internal Pdb trace UI is used on both ``breakpoint()`` and failed tests/unhandled exceptions.
- 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.
- With ``--pdb`` passed to pytest, the custom internal Pdb trace UI is used with both ``breakpoint()`` and failed tests/unhandled exceptions.
- ``--pdbcls`` can be used to specify a custom debugger class.

.. _durations:

Expand Down
5 changes: 5 additions & 0 deletions src/_pytest/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,11 @@ def consider_preparse(self, args):
def consider_pluginarg(self, arg):
if arg.startswith("no:"):
name = arg[3:]
# PR #4304 : remove stepwise if cacheprovider is blocked
if name == "cacheprovider":
self.set_blocked("stepwise")
self.set_blocked("pytest_stepwise")

self.set_blocked(name)
if not name.startswith("pytest_"):
self.set_blocked("pytest_" + name)
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ def execute(self, request):
return hook.pytest_fixture_setup(fixturedef=self, request=request)

def __repr__(self):
return "<FixtureDef name=%r scope=%r baseid=%r>" % (
return "<FixtureDef argname=%r scope=%r baseid=%r>" % (
self.argname,
self.scope,
self.baseid,
Expand Down
6 changes: 3 additions & 3 deletions src/_pytest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def pytest_ignore_collect(path, config):
return True

allow_in_venv = config.getoption("collect_in_virtualenv")
if _in_venv(path) and not allow_in_venv:
if not allow_in_venv and _in_venv(path):
return True

return False
Expand Down Expand Up @@ -511,9 +511,9 @@ def _collect(self, arg):
# No point in finding packages when collecting doctests
if not self.config.option.doctestmodules:
pm = self.config.pluginmanager
for parent in argpath.parts():
for parent in reversed(argpath.parts()):
if pm._confcutdir and pm._confcutdir.relto(parent):
continue
break

if parent.isdir():
pkginit = parent.join("__init__.py")
Expand Down
8 changes: 4 additions & 4 deletions src/_pytest/pytester.py
Original file line number Diff line number Diff line change
Expand Up @@ -1160,11 +1160,11 @@ def runpython_c(self, command):
def runpytest_subprocess(self, *args, **kwargs):
"""Run pytest as a subprocess with given arguments.

Any plugins added to the :py:attr:`plugins` list will added using the
``-p`` command line option. Additionally ``--basetemp`` is used put
Any plugins added to the :py:attr:`plugins` list will be added using the
``-p`` command line option. Additionally ``--basetemp`` is used to put
any temporary files and directories in a numbered directory prefixed
with "runpytest-" so they do not conflict with the normal numbered
pytest location for temporary files and directories.
with "runpytest-" to not conflict with the normal numbered pytest
location for temporary files and directories.

:param args: the sequence of arguments to pass to the pytest subprocess
:param timeout: the period in seconds after which to timeout and raise
Expand Down
5 changes: 4 additions & 1 deletion src/_pytest/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,10 @@ def report_collect(self, final=False):
if not final:
# Only write "collecting" report every 0.5s.
t = time.time()
if self._collect_report_last_write > t - 0.5:
if (
self._collect_report_last_write is not None
and self._collect_report_last_write > t - 0.5
):
return
self._collect_report_last_write = t

Expand Down
3 changes: 2 additions & 1 deletion testing/acceptance_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ class TestGeneralUsage(object):
def test_config_error(self, testdir):
testdir.copy_example("conftest_usageerror/conftest.py")
result = testdir.runpytest(testdir.tmpdir)
assert result.ret != 0
assert result.ret == EXIT_USAGEERROR
result.stderr.fnmatch_lines(["*ERROR: hello"])
result.stdout.fnmatch_lines(["*pytest_unconfigure_called"])

def test_root_conftest_syntax_error(self, testdir):
testdir.makepyfile(conftest="raise SyntaxError\n")
Expand Down
4 changes: 4 additions & 0 deletions testing/example_scripts/conftest_usageerror/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ def pytest_configure(config):
import pytest

raise pytest.UsageError("hello")


def pytest_unconfigure(config):
print("pytest_unconfigure_called")
2 changes: 1 addition & 1 deletion testing/logging/test_fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,5 @@ def test_caplog_captures_for_all_stages(caplog, logging_during_setup_and_teardow

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

# This reachers into private API, don't use this type of thing in real tests!
# This reaches into private API, don't use this type of thing in real tests!
assert set(caplog._item.catch_log_handlers.keys()) == {"setup", "call"}
2 changes: 1 addition & 1 deletion testing/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ def test_with_ini(self, tmpdir, name):
assert inifile == inifile

@pytest.mark.parametrize("name", "setup.cfg tox.ini".split())
def test_pytestini_overides_empty_other(self, tmpdir, name):
def test_pytestini_overrides_empty_other(self, tmpdir, name):
inifile = tmpdir.ensure("pytest.ini")
a = tmpdir.mkdir("a")
a.ensure(name)
Expand Down
14 changes: 10 additions & 4 deletions testing/test_modimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,19 @@ def test_fileimport(modfile):
# without needing the pytest namespace being set
# this is critical for the initialization of xdist

res = subprocess.call(
p = subprocess.Popen(
[
sys.executable,
"-c",
"import sys, py; py.path.local(sys.argv[1]).pyimport()",
modfile.strpath,
]
],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
if res:
pytest.fail("command result %s" % res)
(out, err) = p.communicate()
if p.returncode != 0:
pytest.fail(
"importing %s failed (exitcode %d): out=%r, err=%r"
% (modfile, p.returncode, out, err)
)
18 changes: 18 additions & 0 deletions testing/test_pluginmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,3 +380,21 @@ def test_plugin_prevent_register_unregistered_alredy_registered(self, pytestpm):
pytestpm.consider_preparse(["xyz", "-p", "no:abc"])
l2 = pytestpm.get_plugins()
assert 42 not in l2

def test_plugin_prevent_register_stepwise_on_cacheprovider_unregister(
self, pytestpm
):
""" From PR #4304 : The only way to unregister a module is documented at
the end of https://docs.pytest.org/en/latest/plugins.html.

When unregister cacheprovider, then unregister stepwise too
"""
pytestpm.register(42, name="cacheprovider")
pytestpm.register(43, name="stepwise")
l1 = pytestpm.get_plugins()
assert 42 in l1
assert 43 in l1
pytestpm.consider_preparse(["xyz", "-p", "no:cacheprovider"])
l2 = pytestpm.get_plugins()
assert 42 not in l2
assert 43 not in l2