diff options
author | Ronny Pfannschmidt <opensource@ronnypfannschmidt.de> | 2018-03-17 21:42:43 +0100 |
---|---|---|
committer | Ronny Pfannschmidt <opensource@ronnypfannschmidt.de> | 2018-03-29 17:52:01 +0200 |
commit | 180ae0920235e883138d56fa4274565793058465 (patch) | |
tree | 1b15a645a7ab606f61abc22d17c22d5be76b877b /testing | |
parent | e8feee0612246d4f3414530388c9aee6dd0f563c (diff) | |
download | pytest-180ae0920235e883138d56fa4274565793058465.tar.gz |
deprecate markinfo and fix up most marker scoping access while completely breaking metafunc testing
Diffstat (limited to 'testing')
-rw-r--r-- | testing/python/fixture.py | 4 | ||||
-rw-r--r-- | testing/python/metafunc.py | 8 | ||||
-rw-r--r-- | testing/test_mark.py | 9 |
3 files changed, 19 insertions, 2 deletions
diff --git a/testing/python/fixture.py b/testing/python/fixture.py index 59c5266cb..c558ea3cf 100644 --- a/testing/python/fixture.py +++ b/testing/python/fixture.py @@ -1781,6 +1781,8 @@ class TestAutouseManagement(object): import pytest values = [] def pytest_generate_tests(metafunc): + if metafunc.cls is None: + assert metafunc.function is test_finish if metafunc.cls is not None: metafunc.parametrize("item", [1,2], scope="class") class TestClass(object): @@ -1798,7 +1800,7 @@ class TestAutouseManagement(object): assert values == ["setup-1", "step1-1", "step2-1", "teardown-1", "setup-2", "step1-2", "step2-2", "teardown-2",] """) - reprec = testdir.inline_run() + reprec = testdir.inline_run('-s') reprec.assertoutcome(passed=5) def test_ordering_autouse_before_explicit(self, testdir): diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py index f2732ef3b..b65a42e09 100644 --- a/testing/python/metafunc.py +++ b/testing/python/metafunc.py @@ -26,11 +26,17 @@ class TestMetafunc(object): names = fixtures.getfuncargnames(func) fixtureinfo = FixtureInfo(names) - return python.Metafunc(func, fixtureinfo, config) + definition = python.FunctionDefinition( + name=func.__name__, + parent=None, + callobj=func, + ) + return python.Metafunc(definition, fixtureinfo, config) def test_no_funcargs(self, testdir): def function(): pass + metafunc = self.Metafunc(function) assert not metafunc.fixturenames repr(metafunc._calls) diff --git a/testing/test_mark.py b/testing/test_mark.py index 9f4a7fc88..42c5d8bc5 100644 --- a/testing/test_mark.py +++ b/testing/test_mark.py @@ -8,6 +8,8 @@ from _pytest.mark import ( EMPTY_PARAMETERSET_OPTION, ) +ignore_markinfo = pytest.mark.filterwarnings('ignore:MarkInfo objects:_pytest.deprecated.RemovedInPytest4Warning') + class TestMark(object): def test_markinfo_repr(self): @@ -51,6 +53,7 @@ class TestMark(object): mark.hello(f) assert f.hello + @ignore_markinfo def test_pytest_mark_keywords(self): mark = Mark() @@ -62,6 +65,7 @@ class TestMark(object): assert f.world.kwargs['x'] == 3 assert f.world.kwargs['y'] == 4 + @ignore_markinfo def test_apply_multiple_and_merge(self): mark = Mark() @@ -78,6 +82,7 @@ class TestMark(object): assert f.world.kwargs['y'] == 1 assert len(f.world.args) == 0 + @ignore_markinfo def test_pytest_mark_positional(self): mark = Mark() @@ -88,6 +93,7 @@ class TestMark(object): assert f.world.args[0] == "hello" mark.world("world")(f) + @ignore_markinfo def test_pytest_mark_positional_func_and_keyword(self): mark = Mark() @@ -103,6 +109,7 @@ class TestMark(object): assert g.world.args[0] is f assert g.world.kwargs["omega"] == "hello" + @ignore_markinfo def test_pytest_mark_reuse(self): mark = Mark() @@ -484,6 +491,7 @@ class TestFunctional(object): assert 'hello' in keywords assert 'world' in keywords + @ignore_markinfo def test_merging_markers(self, testdir): p = testdir.makepyfile(""" import pytest @@ -621,6 +629,7 @@ class TestFunctional(object): "keyword: *hello*" ]) + @ignore_markinfo def test_merging_markers_two_functions(self, testdir): p = testdir.makepyfile(""" import pytest |