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

Clarify PytestPluginManager._is_in_confcutdir #12007

Merged
merged 2 commits into from Feb 18, 2024

Conversation

nicoddemus
Copy link
Member

Follow up to #12006, let's put some comments clarifying is_in_confcutdir semantics, as this is not the first time someone misunderstands it.

Also removed an obsolete comment in _loadconftestmodules: we already set the confcutdir based on rootdir/initfile if not explicitly given.

Follow up to pytest-dev#12006, let's put some comments clarifying `is_in_confcutdir` semantics, as this is not the first time someone misunderstands it.

Also removed an obsolete comment in `_loadconftestmodules`: we already set the `confcutdir` based on `rootdir`/`initfile` if not explicitly given.
@@ -578,12 +578,18 @@ def _set_initial_conftests(
self._try_load_conftest(invocation_dir, importmode, rootpath)

def _is_in_confcutdir(self, path: Path) -> bool:
Copy link
Member Author

Choose a reason for hiding this comment

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

How about renaming this to focus on the purpose of the method rather than the implementation detail?

Suggested change
def _is_in_confcutdir(self, path: Path) -> bool:
def _should_load_conftests_from(self, path: Path) -> bool:

@@ -609,9 +615,6 @@ def _loadconftestmodules(
if directory in self._dirpath2confmods:
return

# XXX these days we may rather want to use config.rootpath
Copy link
Member Author

Choose a reason for hiding this comment

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

This comment is outdated, we always configure confcutdir nowadays:

if self.known_args_namespace.confcutdir is None:
if self.inipath is not None:
confcutdir = str(self.inipath.parent)
else:
confcutdir = str(self.rootpath)
self.known_args_namespace.confcutdir = confcutdir

src/_pytest/config/__init__.py Outdated Show resolved Hide resolved
Co-authored-by: Ran Benita <ran@unusedvar.com>
@nicoddemus nicoddemus merged commit 998fee1 into pytest-dev:main Feb 18, 2024
24 checks passed
@nicoddemus nicoddemus deleted the confcutdir-docs branch February 18, 2024 20:27
flying-sheep pushed a commit to flying-sheep/pytest that referenced this pull request Apr 9, 2024
Follow up to pytest-dev#12006, let's put some comments clarifying `is_in_confcutdir` semantics, as this is not the first time someone misunderstands it.

Also removed an obsolete comment in `_loadconftestmodules`: we already set the `confcutdir` based on `rootdir`/`initfile` if not explicitly given.

Co-authored-by: Ran Benita <ran@unusedvar.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants