parent
b840622819
commit
7248b759e8
|
@ -25,7 +25,6 @@ def pytest_addoption(parser):
|
|||
expression information.""")
|
||||
|
||||
|
||||
|
||||
def register_assert_rewrite(*names):
|
||||
"""Register one or more module names to be rewritten on import.
|
||||
|
||||
|
|
|
@ -215,8 +215,6 @@ class AssertionRewritingHook(object):
|
|||
raise
|
||||
return sys.modules[name]
|
||||
|
||||
|
||||
|
||||
def is_package(self, name):
|
||||
try:
|
||||
fd, fn, desc = imp.find_module(name)
|
||||
|
@ -900,7 +898,6 @@ class AssertionRewriter(ast.NodeVisitor):
|
|||
else:
|
||||
visit_Call = visit_Call_legacy
|
||||
|
||||
|
||||
def visit_Attribute(self, attr):
|
||||
if not isinstance(attr.ctx, ast.Load):
|
||||
return self.generic_visit(attr)
|
||||
|
|
|
@ -180,7 +180,6 @@ def pytest_cmdline_main(config):
|
|||
return wrap_session(config, cacheshow)
|
||||
|
||||
|
||||
|
||||
@pytest.hookimpl(tryfirst=True)
|
||||
def pytest_configure(config):
|
||||
config.cache = Cache(config)
|
||||
|
|
|
@ -13,7 +13,6 @@ import py
|
|||
import _pytest
|
||||
|
||||
|
||||
|
||||
try:
|
||||
import enum
|
||||
except ImportError: # pragma: no cover
|
||||
|
@ -111,7 +110,6 @@ def getfuncargnames(function, startindex=None):
|
|||
return tuple(argnames[startindex:])
|
||||
|
||||
|
||||
|
||||
if sys.version_info[:2] == (2, 6):
|
||||
def isclass(object):
|
||||
""" Return true if the object is a class. Overrides inspect.isclass for
|
||||
|
|
|
@ -851,7 +851,6 @@ class DropShorterLongHelpFormatter(argparse.HelpFormatter):
|
|||
return action._formatted_action_invocation
|
||||
|
||||
|
||||
|
||||
def _ensure_removed_sysmodule(modname):
|
||||
try:
|
||||
del sys.modules[modname]
|
||||
|
|
|
@ -4,7 +4,6 @@ import pdb
|
|||
import sys
|
||||
|
||||
|
||||
|
||||
def pytest_addoption(parser):
|
||||
group = parser.getgroup("general")
|
||||
group._addoption(
|
||||
|
|
|
@ -116,7 +116,6 @@ def add_funcarg_pseudo_fixture_def(collector, metafunc, fixturemanager):
|
|||
node._name2pseudofixturedef[argname] = fixturedef
|
||||
|
||||
|
||||
|
||||
def getfixturemarker(obj):
|
||||
""" return fixturemarker or None if it doesn't exist or raised
|
||||
exceptions."""
|
||||
|
@ -128,7 +127,6 @@ def getfixturemarker(obj):
|
|||
return None
|
||||
|
||||
|
||||
|
||||
def get_parametrized_fixture_keys(item, scopenum):
|
||||
""" return list of keys for all parametrized arguments which match
|
||||
the specified scope. """
|
||||
|
@ -240,7 +238,6 @@ def fillfixtures(function):
|
|||
request._fillfixtures()
|
||||
|
||||
|
||||
|
||||
def get_direct_param_fixture_func(request):
|
||||
return request.param
|
||||
|
||||
|
@ -283,7 +280,6 @@ class FixtureRequest(FuncargnamesCompatAttr):
|
|||
""" underlying collection node (depends on current request scope)"""
|
||||
return self._getscopeitem(self.scope)
|
||||
|
||||
|
||||
def _getnextfixturedef(self, argname):
|
||||
fixturedefs = self._arg2fixturedefs.get(argname, None)
|
||||
if fixturedefs is None:
|
||||
|
@ -305,7 +301,6 @@ class FixtureRequest(FuncargnamesCompatAttr):
|
|||
""" the pytest config object associated with this request. """
|
||||
return self._pyfuncitem.config
|
||||
|
||||
|
||||
@scopeproperty()
|
||||
def function(self):
|
||||
""" test function object if the request has a per-function scope. """
|
||||
|
@ -839,7 +834,6 @@ class FixtureFunctionMarker:
|
|||
return function
|
||||
|
||||
|
||||
|
||||
def fixture(scope="function", params=None, autouse=False, ids=None, name=None):
|
||||
""" (return a) decorator to mark a fixture factory function.
|
||||
|
||||
|
@ -955,7 +949,6 @@ class FixtureManager:
|
|||
self._nodeid_and_autousenames = [("", self.config.getini("usefixtures"))]
|
||||
session.config.pluginmanager.register(self, "funcmanage")
|
||||
|
||||
|
||||
def getfixtureinfo(self, node, func, cls, funcargs=True):
|
||||
if funcargs and not hasattr(node, "nofuncargs"):
|
||||
if cls is not None:
|
||||
|
|
|
@ -5,7 +5,6 @@ pytest
|
|||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
|
||||
|
||||
def freeze_includes():
|
||||
"""
|
||||
Returns a list of module names used by py.test that should be
|
||||
|
|
|
@ -77,7 +77,6 @@ def pytest_addoption(parser):
|
|||
help="base temporary directory for this test run.")
|
||||
|
||||
|
||||
|
||||
def pytest_namespace():
|
||||
"""keeping this one works around a deeper startup issue in pytest
|
||||
|
||||
|
@ -217,7 +216,6 @@ class _CompatProperty(object):
|
|||
return getattr(__import__('pytest'), self.name)
|
||||
|
||||
|
||||
|
||||
class NodeKeywords(MappingMixin):
|
||||
def __init__(self, node):
|
||||
self.node = node
|
||||
|
|
|
@ -245,7 +245,6 @@ class MarkGenerator:
|
|||
on the ``test_function`` object. """
|
||||
_config = None
|
||||
|
||||
|
||||
def __getattr__(self, name):
|
||||
if name[0] == "_":
|
||||
raise AttributeError("Marker name must NOT start with underscore")
|
||||
|
@ -356,9 +355,6 @@ class MarkDecorator:
|
|||
return self.__class__(self.mark.combined_with(mark))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class Mark(namedtuple('Mark', 'name, args, kwargs')):
|
||||
|
||||
def combined_with(self, other):
|
||||
|
|
|
@ -390,7 +390,6 @@ class RunResult:
|
|||
assert failed == d.get("failed", 0)
|
||||
|
||||
|
||||
|
||||
class Testdir:
|
||||
"""Temporary test directory with tools to test/run pytest itself.
|
||||
|
||||
|
|
|
@ -48,7 +48,6 @@ def filter_traceback(entry):
|
|||
return p != cutdir1 and not p.relto(cutdir2) and not p.relto(cutdir3)
|
||||
|
||||
|
||||
|
||||
def pyobj_property(name):
|
||||
def get(self):
|
||||
node = self.getparent(getattr(__import__('pytest'), name))
|
||||
|
@ -193,7 +192,6 @@ def pytest_make_parametrize_id(config, val, argname=None):
|
|||
return None
|
||||
|
||||
|
||||
|
||||
class PyobjContext(object):
|
||||
module = pyobj_property("Module")
|
||||
cls = pyobj_property("Class")
|
||||
|
|
|
@ -509,7 +509,6 @@ class TerminalReporter:
|
|||
content = content[:-1]
|
||||
self._tw.line(content)
|
||||
|
||||
|
||||
def summary_failures(self):
|
||||
if self.config.option.tbstyle != "no":
|
||||
reports = self.getreports('failed')
|
||||
|
|
|
@ -81,7 +81,6 @@ class TestGeneralUsage(object):
|
|||
"*---unconfigure",
|
||||
])
|
||||
|
||||
|
||||
def test_config_preparse_plugin_option(self, testdir):
|
||||
testdir.makepyfile(pytest_xyz="""
|
||||
def pytest_addoption(parser):
|
||||
|
@ -147,7 +146,6 @@ class TestGeneralUsage(object):
|
|||
*ERROR*could not load*conftest.py*
|
||||
""")
|
||||
|
||||
|
||||
def test_early_skip(self, testdir):
|
||||
testdir.mkdir("xyz")
|
||||
testdir.makeconftest("""
|
||||
|
@ -676,7 +674,6 @@ class TestInvocationVariants(object):
|
|||
import _pytest.config
|
||||
assert type(_pytest.config.get_plugin_manager()) is _pytest.config.PytestPluginManager
|
||||
|
||||
|
||||
def test_has_plugin(self, request):
|
||||
"""Test hasplugin function of the plugin manager (#932)."""
|
||||
assert request.config.pluginmanager.hasplugin('python')
|
||||
|
|
|
@ -467,7 +467,6 @@ class TestFormattedExcinfo(object):
|
|||
'E AssertionError'
|
||||
]
|
||||
|
||||
|
||||
def test_repr_source_not_existing(self):
|
||||
pr = FormattedExcinfo()
|
||||
co = compile("raise ValueError()", "", "exec")
|
||||
|
@ -553,14 +552,12 @@ raise ValueError()
|
|||
if py.std.sys.version_info[0] >= 3:
|
||||
assert repr.chain[0][0].reprentries[0].lines[0] == "> ???"
|
||||
|
||||
|
||||
fail = py.error.ENOENT # noqa
|
||||
repr = pr.repr_excinfo(excinfo)
|
||||
assert repr.reprtraceback.reprentries[0].lines[0] == "> ???"
|
||||
if py.std.sys.version_info[0] >= 3:
|
||||
assert repr.chain[0][0].reprentries[0].lines[0] == "> ???"
|
||||
|
||||
|
||||
def test_repr_local(self):
|
||||
p = FormattedExcinfo(showlocals=True)
|
||||
loc = {'y': 5, 'z': 7, 'x': 3, '@x': 2, '__builtins__': {}}
|
||||
|
|
|
@ -642,7 +642,6 @@ finally:
|
|||
assert str(source) == " raise IndexError(1)"
|
||||
|
||||
|
||||
|
||||
class TestIf(object):
|
||||
pytestmark = astonly
|
||||
source = """\
|
||||
|
|
|
@ -476,7 +476,6 @@ class TestFunction(object):
|
|||
rec = testdir.inline_run()
|
||||
rec.assertoutcome(passed=2)
|
||||
|
||||
|
||||
def test_parametrize_with_non_hashable_values_indirect(self, testdir):
|
||||
"""Test parametrization with non-hashable values with indirect parametrization."""
|
||||
testdir.makepyfile("""
|
||||
|
@ -504,7 +503,6 @@ class TestFunction(object):
|
|||
rec = testdir.inline_run()
|
||||
rec.assertoutcome(passed=2)
|
||||
|
||||
|
||||
def test_parametrize_overrides_fixture(self, testdir):
|
||||
"""Test parametrization when parameter overrides existing fixture with same name."""
|
||||
testdir.makepyfile("""
|
||||
|
@ -532,7 +530,6 @@ class TestFunction(object):
|
|||
rec = testdir.inline_run()
|
||||
rec.assertoutcome(passed=3)
|
||||
|
||||
|
||||
def test_parametrize_overrides_parametrized_fixture(self, testdir):
|
||||
"""Test parametrization when parameter overrides existing parametrized fixture with same name."""
|
||||
testdir.makepyfile("""
|
||||
|
@ -1352,7 +1349,6 @@ def test_skip_duplicates_by_default(testdir):
|
|||
])
|
||||
|
||||
|
||||
|
||||
def test_keep_duplicates(testdir):
|
||||
"""Test for issue https://github.com/pytest-dev/pytest/issues/1609 (#1609)
|
||||
|
||||
|
|
|
@ -441,7 +441,6 @@ class TestFillFixtures(object):
|
|||
])
|
||||
assert "INTERNAL" not in result.stdout.str()
|
||||
|
||||
|
||||
def test_fixture_excinfo_leak(self, testdir):
|
||||
# on python2 sys.excinfo would leak into fixture executions
|
||||
testdir.makepyfile("""
|
||||
|
@ -641,7 +640,6 @@ class TestRequestBasic(object):
|
|||
mod = reprec.getcalls("pytest_runtest_setup")[0].item.module
|
||||
assert not mod.l
|
||||
|
||||
|
||||
def test_request_addfinalizer_partial_setup_failure(self, testdir):
|
||||
p = testdir.makepyfile("""
|
||||
import pytest
|
||||
|
@ -1603,8 +1601,6 @@ class TestAutouseManagement(object):
|
|||
reprec = testdir.inline_run()
|
||||
reprec.assertoutcome(passed=2)
|
||||
|
||||
|
||||
|
||||
def test_funcarg_and_setup(self, testdir):
|
||||
testdir.makepyfile("""
|
||||
import pytest
|
||||
|
@ -2406,7 +2402,6 @@ class TestFixtureMarker(object):
|
|||
reprec = testdir.inline_run("-v")
|
||||
reprec.assertoutcome(passed=5)
|
||||
|
||||
|
||||
@pytest.mark.issue246
|
||||
@pytest.mark.parametrize("scope", ["session", "function", "module"])
|
||||
def test_finalizer_order_on_parametrization(self, scope, testdir):
|
||||
|
@ -2638,8 +2633,6 @@ class TestErrors(object):
|
|||
*3 pass*2 error*
|
||||
""")
|
||||
|
||||
|
||||
|
||||
def test_setupfunc_missing_funcarg(self, testdir):
|
||||
testdir.makepyfile("""
|
||||
import pytest
|
||||
|
@ -2747,7 +2740,6 @@ class TestShowFixtures(object):
|
|||
|
||||
""")
|
||||
|
||||
|
||||
def test_show_fixtures_different_files(self, testdir):
|
||||
"""
|
||||
#833: --fixtures only shows fixtures from first file
|
||||
|
|
|
@ -331,7 +331,6 @@ class TestMetafunc(object):
|
|||
"\nUpdate your code as this will raise an error in pytest-4.0.",
|
||||
]
|
||||
|
||||
|
||||
def test_parametrize_ids_exception(self, testdir):
|
||||
"""
|
||||
:param testdir: the instance of Testdir class, a temporary
|
||||
|
@ -776,7 +775,6 @@ class TestMetafuncFunctional(object):
|
|||
result = testdir.runpytest(p)
|
||||
result.assert_outcomes(passed=1)
|
||||
|
||||
|
||||
def test_generate_plugin_and_module(self, testdir):
|
||||
testdir.makeconftest("""
|
||||
def pytest_generate_tests(metafunc):
|
||||
|
@ -1435,7 +1433,6 @@ class TestMarkersWithParametrization(object):
|
|||
reprec = testdir.inline_run()
|
||||
reprec.assertoutcome(passed=2, skipped=2)
|
||||
|
||||
|
||||
@pytest.mark.issue290
|
||||
def test_parametrize_ID_generation_string_int_works(self, testdir):
|
||||
testdir.makepyfile("""
|
||||
|
@ -1452,7 +1449,6 @@ class TestMarkersWithParametrization(object):
|
|||
reprec = testdir.inline_run()
|
||||
reprec.assertoutcome(passed=2)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('strict', [True, False])
|
||||
def test_parametrize_marked_value(self, testdir, strict):
|
||||
s = """
|
||||
|
@ -1476,7 +1472,6 @@ class TestMarkersWithParametrization(object):
|
|||
passed, failed = (0, 2) if strict else (2, 0)
|
||||
reprec.assertoutcome(passed=passed, failed=failed)
|
||||
|
||||
|
||||
def test_pytest_make_parametrize_id(self, testdir):
|
||||
testdir.makeconftest("""
|
||||
def pytest_make_parametrize_id(config, val):
|
||||
|
|
|
@ -118,7 +118,6 @@ class TestRaises(object):
|
|||
for o in gc.get_objects():
|
||||
assert type(o) is not T
|
||||
|
||||
|
||||
def test_raises_match(self):
|
||||
msg = r"with base \d+"
|
||||
with pytest.raises(ValueError, match=msg):
|
||||
|
|
|
@ -89,7 +89,6 @@ class TestNewAPI(object):
|
|||
result.stdout.fnmatch_lines(["*1 passed*"])
|
||||
|
||||
|
||||
|
||||
def test_cache_reportheader(testdir):
|
||||
testdir.makepyfile("""
|
||||
def test_hello():
|
||||
|
@ -339,7 +338,6 @@ class TestLastFailed(object):
|
|||
lastfailed = rlf(fail_import=0, fail_run=1)
|
||||
assert list(lastfailed) == ['test_maybe.py::test_hello']
|
||||
|
||||
|
||||
def test_lastfailed_failure_subset(self, testdir, monkeypatch):
|
||||
|
||||
testdir.makepyfile(test_maybe="""
|
||||
|
@ -381,12 +379,10 @@ class TestLastFailed(object):
|
|||
result, lastfailed = rlf(fail_import=1, fail_run=0)
|
||||
assert sorted(list(lastfailed)) == ['test_maybe.py', 'test_maybe2.py']
|
||||
|
||||
|
||||
result, lastfailed = rlf(fail_import=0, fail_run=0,
|
||||
args=('test_maybe2.py',))
|
||||
assert list(lastfailed) == ['test_maybe.py']
|
||||
|
||||
|
||||
# edge case of test selection - even if we remember failures
|
||||
# from other tests we still need to run all tests if no test
|
||||
# matches the failures
|
||||
|
|
|
@ -49,7 +49,6 @@ def oswritebytes(fd, obj):
|
|||
os.write(fd, tobytes(obj))
|
||||
|
||||
|
||||
|
||||
def StdCaptureFD(out=True, err=True, in_=True):
|
||||
return capture.MultiCapture(out, err, in_, Capture=capture.FDCapture)
|
||||
|
||||
|
@ -1076,7 +1075,6 @@ def test_close_and_capture_again(testdir):
|
|||
""")
|
||||
|
||||
|
||||
|
||||
@pytest.mark.parametrize('method', ['SysCapture', 'FDCapture'])
|
||||
def test_capturing_and_logging_fundamentals(testdir, method):
|
||||
if method == "StdCaptureFD" and not hasattr(os, 'dup'):
|
||||
|
|
|
@ -69,7 +69,6 @@ class TestCollector(object):
|
|||
parent = fn.getparent(pytest.Class)
|
||||
assert parent is cls
|
||||
|
||||
|
||||
def test_getcustomfile_roundtrip(self, testdir):
|
||||
hello = testdir.makefile(".xxx", hello="world")
|
||||
testdir.makepyfile(conftest="""
|
||||
|
|
|
@ -731,7 +731,6 @@ class TestOverrideIniArgs(object):
|
|||
assert result.ret == 0
|
||||
result.stdout.fnmatch_lines(["custom_option:3.0"])
|
||||
|
||||
|
||||
def test_override_ini_pathlist(self, testdir):
|
||||
testdir.makeconftest("""
|
||||
def pytest_addoption(parser):
|
||||
|
|
|
@ -294,7 +294,6 @@ class TestDoctests(object):
|
|||
"*:5: DocTestFailure"
|
||||
])
|
||||
|
||||
|
||||
def test_txtfile_failing(self, testdir):
|
||||
p = testdir.maketxtfile("""
|
||||
>>> i = 0
|
||||
|
|
|
@ -462,7 +462,6 @@ class TestFunctional(object):
|
|||
items, rec = testdir.inline_genitems(p)
|
||||
self.assert_markers(items, test_foo=('a', 'b'), test_bar=('a',))
|
||||
|
||||
|
||||
@pytest.mark.issue568
|
||||
@pytest.mark.xfail(reason="markers smear on methods of base classes")
|
||||
def test_mark_should_not_pass_to_siebling_class(self, testdir):
|
||||
|
@ -487,7 +486,6 @@ class TestFunctional(object):
|
|||
assert not hasattr(base_item.obj, 'b')
|
||||
assert not hasattr(sub_item_other.obj, 'b')
|
||||
|
||||
|
||||
def test_mark_decorator_baseclasses_merged(self, testdir):
|
||||
p = testdir.makepyfile("""
|
||||
import pytest
|
||||
|
|
|
@ -33,7 +33,6 @@ def custom_pdb_calls():
|
|||
return called
|
||||
|
||||
|
||||
|
||||
class TestPDB(object):
|
||||
|
||||
@pytest.fixture
|
||||
|
@ -377,7 +376,6 @@ class TestPDB(object):
|
|||
])
|
||||
assert custom_pdb_calls == ["init", "reset", "interaction"]
|
||||
|
||||
|
||||
def test_pdb_custom_cls_without_pdb(self, testdir, custom_pdb_calls):
|
||||
p1 = testdir.makepyfile("""xxx """)
|
||||
result = testdir.runpytest_inprocess(
|
||||
|
|
|
@ -295,7 +295,6 @@ class TestWarns(object):
|
|||
assert str(record[0].message) == "user"
|
||||
assert str(record[1].message) == "runtime"
|
||||
|
||||
|
||||
def test_double_test(self, testdir):
|
||||
"""If a test is run again, the warning should still be raised"""
|
||||
testdir.makepyfile('''
|
||||
|
|
|
@ -350,7 +350,6 @@ class TestXFail(object):
|
|||
"*1 xfailed*",
|
||||
])
|
||||
|
||||
|
||||
@pytest.mark.parametrize('expected, actual, matchline',
|
||||
[('TypeError', 'TypeError', "*1 xfailed*"),
|
||||
('(AttributeError, TypeError)', 'TypeError', "*1 xfailed*"),
|
||||
|
|
|
@ -734,7 +734,6 @@ class TestGenericReporting(object):
|
|||
"*2 failed*",
|
||||
])
|
||||
|
||||
|
||||
def test_tb_option(self, testdir, option):
|
||||
testdir.makepyfile("""
|
||||
import pytest
|
||||
|
|
|
@ -113,7 +113,6 @@ def test_ignore(testdir, pyfile_with_warnings, method):
|
|||
assert WARNINGS_SUMMARY_HEADER not in result.stdout.str()
|
||||
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.version_info < (3, 0),
|
||||
reason='warnings message is unicode is ok in python3')
|
||||
def test_unicode(testdir, pyfile_with_warnings):
|
||||
|
|
2
tox.ini
2
tox.ini
|
@ -196,6 +196,6 @@ filterwarnings =
|
|||
ignore:.*inspect.getargspec.*deprecated, use inspect.signature.*:DeprecationWarning
|
||||
|
||||
[flake8]
|
||||
ignore = E303,E401,E402,E501,E701,E702,E704,E712,E731
|
||||
ignore = E401,E402,E501,E701,E702,E704,E712,E731
|
||||
max-line-length = 120
|
||||
exclude = _pytest/vendored_packages/pluggy.py
|
||||
|
|
Loading…
Reference in New Issue