Merge pull request #4354 from blueyed/minor
A set of minor changes from my Git stashes
This commit is contained in:
commit
afaad2f82b
|
@ -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:
|
||||
|
||||
|
|
|
@ -927,7 +927,7 @@ class FixtureDef(object):
|
|||
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,
|
||||
|
|
|
@ -278,7 +278,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
|
||||
|
@ -495,9 +495,9 @@ class Session(nodes.FSCollector):
|
|||
# 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")
|
||||
|
|
|
@ -1160,11 +1160,11 @@ class Testdir(object):
|
|||
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
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -2,3 +2,7 @@ def pytest_configure(config):
|
|||
import pytest
|
||||
|
||||
raise pytest.UsageError("hello")
|
||||
|
||||
|
||||
def pytest_unconfigure(config):
|
||||
print("pytest_unconfigure_called")
|
||||
|
|
|
@ -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"}
|
||||
|
|
|
@ -874,7 +874,7 @@ class TestRootdir(object):
|
|||
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)
|
||||
|
|
Loading…
Reference in New Issue