Skip to content
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

Fix non-sensical error message #9077

Merged
merged 4 commits into from Sep 24, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions testing/python/fixtures.py
Expand Up @@ -1092,6 +1092,26 @@ def test_1(arg):
reprec = pytester.inline_run()
reprec.assertoutcome(passed=2)

@pytest.mark.parametrize("name", ["path", "fspath", "module"])
def test_session_scoped_unavailable_attributes(self, pytester, name):
pytester.makepyfile(
f"""
import pytest
Copy link
Member

Choose a reason for hiding this comment

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

i really wish we could do tests like this one as unittest

Copy link
Member Author

Choose a reason for hiding this comment

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

IMHO that'd require fixtures to be importable/scoped in some way, rather than essentially being global state.


@pytest.fixture(scope="session")
def fixt(request):
request.{name}

def test_request(fixt):
pass
"""
)
result = pytester.runpytest()
expected = "path" if name == "fspath" else name
result.stdout.fnmatch_lines(
[f"E*AttributeError: {expected} not available in session-scoped context"]
)


class TestRequestMarking:
def test_applymarker(self, pytester: Pytester) -> None:
Expand Down