Skip to content

Commit afaad2f

Browse files
authored
Merge pull request #4354 from blueyed/minor
A set of minor changes from my Git stashes
2 parents d4fdf79 + feccf53 commit afaad2f

File tree

8 files changed

+18
-13
lines changed

8 files changed

+18
-13
lines changed

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/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
@@ -278,7 +278,7 @@ def pytest_ignore_collect(path, config):
278278
return True
279279

280280
allow_in_venv = config.getoption("collect_in_virtualenv")
281-
if _in_venv(path) and not allow_in_venv:
281+
if not allow_in_venv and _in_venv(path):
282282
return True
283283

284284
return False
@@ -495,9 +495,9 @@ def _collect(self, arg):
495495
# No point in finding packages when collecting doctests
496496
if not self.config.option.doctestmodules:
497497
pm = self.config.pluginmanager
498-
for parent in argpath.parts():
498+
for parent in reversed(argpath.parts()):
499499
if pm._confcutdir and pm._confcutdir.relto(parent):
500-
continue
500+
break
501501

502502
if parent.isdir():
503503
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

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)

0 commit comments

Comments
 (0)