Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/11333.trivial.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Corrected the spelling of ``Config.ArgsSource.INVOCATION_DIR``.
5 changes: 3 additions & 2 deletions src/_pytest/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,8 @@ class ArgsSource(enum.Enum):
#: 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 @@ def _decide_args(
else:
result = []
if not result:
source = Config.ArgsSource.INCOVATION_DIR
source = Config.ArgsSource.INVOCATION_DIR
result = [str(invocation_dir)]
return result, source

Expand Down
18 changes: 18 additions & 0 deletions testing/test_config.py
Original file line number Diff line number Diff line change
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