Skip to content

[WIP] classmethod and class-scoped fixtures (#3778) #3781

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/_pytest/pytester.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should use !r

)

Session = Session

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pytest


class Test(object):
@classmethod
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the order in-correctness i was talking about in #3780 - we structurally have to loose something as long as we wrap

@pytest.fixture(scope="class", autouse=True)
def setup(cls):
cls.url = "localhost:5000"

def test_url(self):
assert self.url == "localhost:5000"
5 changes: 5 additions & 0 deletions testing/python/fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
"""
Expand Down