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

Correct the spelling of ArgSource.INVOCATION_DIR #11333

Merged
merged 3 commits into from Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
1 change: 1 addition & 0 deletions changelog/11333.trivial.rst
@@ -0,0 +1 @@
Corrected the spelling of ``Config.ArgsSource.INVOCATION_DIR``.
bluetech marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 3 additions & 2 deletions src/_pytest/config/__init__.py
Expand Up @@ -953,7 +953,8 @@
#: Command line arguments.
ARGS = enum.auto()
#: Invocation directory.
INCOVATION_DIR = enum.auto()
INVOCATION_DIR = enum.auto()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If there are backwards-compatibility concerns, we could also add an alias:

INCOVATION_DIR = INVOCATION_DIR

Copy link
Member

Choose a reason for hiding this comment

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

Yes, we should add an alias, otherwise it'd be a breaking change.

INCOVATION_DIR = INVOCATION_DIR # backwards compatibility alias
#: 'testpaths' configuration value.
TESTPATHS = enum.auto()

Expand Down Expand Up @@ -1278,7 +1279,7 @@
else:
result = []
if not result:
source = Config.ArgsSource.INCOVATION_DIR
source = Config.ArgsSource.INVOCATION_DIR

Check warning on line 1282 in src/_pytest/config/__init__.py

View check run for this annotation

Codecov / codecov/patch

src/_pytest/config/__init__.py#L1282

Added line #L1282 was not covered by tests
result = [str(invocation_dir)]
return result, source

Expand Down
18 changes: 18 additions & 0 deletions testing/test_config.py
Expand Up @@ -507,6 +507,24 @@ def pytest_load_initial_conftests(early_config, parser, args):
result = pytester.runpytest("--foo=1")
result.stdout.fnmatch_lines("* no tests ran in *")

def test_args_source_args(self, pytester: Pytester):
config = pytester.parseconfig("--", "test_filename.py")
assert config.args_source == Config.ArgsSource.ARGS

def test_args_source_invocation_dir(self, pytester: Pytester):
config = pytester.parseconfig()
assert config.args_source == Config.ArgsSource.INVOCATION_DIR

def test_args_source_testpaths(self, pytester: Pytester):
pytester.makeini(
"""
[pytest]
testpaths=*
"""
)
config = pytester.parseconfig()
assert config.args_source == Config.ArgsSource.TESTPATHS


class TestConfigCmdlineParsing:
def test_parsing_again_fails(self, pytester: Pytester) -> None:
Expand Down