diff --git a/src/_pytest/pytester.py b/src/_pytest/pytester.py index 5b42b81eedf..5647df41592 100644 --- a/src/_pytest/pytester.py +++ b/src/_pytest/pytester.py @@ -667,7 +667,9 @@ def copy_example(self, name=None): example_path.copy(result) return result else: - raise LookupError("example is not found as a file or directory") + raise LookupError( + "example {} is not found as a file or directory".format(example_path) + ) Session = Session diff --git a/testing/example_scripts/fixtures/fill_fixtures/class_variable_auto_use.py b/testing/example_scripts/fixtures/fill_fixtures/class_variable_auto_use.py new file mode 100644 index 00000000000..58d56d782b1 --- /dev/null +++ b/testing/example_scripts/fixtures/fill_fixtures/class_variable_auto_use.py @@ -0,0 +1,11 @@ +import pytest + + +class Test(object): + @classmethod + @pytest.fixture(scope="class", autouse=True) + def setup(cls): + cls.url = "localhost:5000" + + def test_url(self): + assert self.url == "localhost:5000" diff --git a/testing/python/fixture.py b/testing/python/fixture.py index bbfcf775be4..1d43b3a2740 100644 --- a/testing/python/fixture.py +++ b/testing/python/fixture.py @@ -371,6 +371,11 @@ def test_foo(request): result = testdir.runpytest() assert result.ret == 0 + def test_class_variable_auto_use(self, testdir): + p = testdir.copy_example("class_variable_auto_use.py") + result = testdir.runpytest(p) + result.stdout.fnmatch_lines("* 1 passed *") + def test_funcarg_lookup_error(self, testdir): testdir.makeconftest( """