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

config: fallback confcutdir to rootpath if inipath is not set #11043

Merged
merged 1 commit into from May 30, 2023

Conversation

bluetech
Copy link
Member

Currently, if --confcutdir is not set, inipath.parent is used, and if initpath is not set, then confcutdir is None, which means there is no cutoff.

Having no cutoff is not great, it means we potentially start probing stuff all the way up to the filesystem root directory. So let's add another fallback, to rootpath, which is always something reasonable.

@@ -0,0 +1,3 @@
In cases when `--confcutdir` is not specified, and there is no config file present, the conftest cutoff directory (confcutdir) is now set to the :ref:`rootdir`.
Previously in such cases, conftest.py files will be probed all the way to the root directory of the filesystem.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Previously in such cases, conftest.py files will be probed all the way to the root directory of the filesystem.
Previously in such cases, `conftest.py` files would be probed all the way to the root directory of the filesystem.

@@ -0,0 +1,3 @@
In cases when `--confcutdir` is not specified, and there is no config file present, the conftest cutoff directory (confcutdir) is now set to the :ref:`rootdir`.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
In cases when `--confcutdir` is not specified, and there is no config file present, the conftest cutoff directory (confcutdir) is now set to the :ref:`rootdir`.
In cases when `--confcutdir` is not specified, and there is no config file present, the conftest cutoff directory (`--confcutdir`) is now set to the :ref:`rootdir`.

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

Choose a reason for hiding this comment

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

It would be good to have a more specific test for this change.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added!

Currently, if `--confcutdir` is not set, `inipath.parent` is used, and
if `initpath` is not set, then `confcutdir` is None, which means there
is no cutoff.

Having no cutoff is not great, it means we potentially start probing
stuff all the way up to the filesystem root directory. So let's add
another fallback, to `rootpath`, which is always something reasonable.
Copy link
Member Author

@bluetech bluetech left a comment

Choose a reason for hiding this comment

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

Thanks for the review @nicoddemus, I applied your suggestions.

if self.inipath is not None:
confcutdir = str(self.inipath.parent)
else:
confcutdir = str(self.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.

Added!

@bluetech bluetech enabled auto-merge May 30, 2023 17:10
@bluetech bluetech merged commit 24534cd into pytest-dev:main May 30, 2023
25 checks passed
@bluetech bluetech deleted the confcutdir-rootpath branch May 31, 2023 07:44
manu0x0 pushed a commit to isc-projects/bind9 that referenced this pull request Jul 20, 2023
In pytest 7.4.0, there were some changes to how the configuration file
for pytest is located. In our case, this resulted in a failure to find
the conftest.py with the needed fixtures which then prevented our python
tests from being executed successfully.

Configure the --confcutdir to ensure it points to the system test
directory, where our conftest.py is located.

Related pytest-dev/pytest#11043
freebsd-git pushed a commit to freebsd/freebsd-src that referenced this pull request Jul 21, 2023
As of pytest 7.4 it no longer walks all the way to the root directory
of the file system to find conftest files. As a result we don't find /
usr/tests/conftest.py, and don't load atf_python. That in turn causes
atf_python tests to fail.

Explicitly set the confcutdir, as advised by the pytest changelog.

See also:	pytest-dev/pytest#11043
MFC after:	3 weeks
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D41064
freebsd-git pushed a commit to freebsd/freebsd-src that referenced this pull request Aug 4, 2023
As of pytest 7.4 it no longer walks all the way to the root directory
of the file system to find conftest files. As a result we don't find /
usr/tests/conftest.py, and don't load atf_python. That in turn causes
atf_python tests to fail.

Explicitly set the confcutdir, as advised by the pytest changelog.

See also:	pytest-dev/pytest#11043
MFC after:	3 weeks
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D41064

(cherry picked from commit 9f23cbd)
bsdjhb pushed a commit to bsdjhb/cheribsd that referenced this pull request Sep 6, 2023
As of pytest 7.4 it no longer walks all the way to the root directory
of the file system to find conftest files. As a result we don't find /
usr/tests/conftest.py, and don't load atf_python. That in turn causes
atf_python tests to fail.

Explicitly set the confcutdir, as advised by the pytest changelog.

See also:	pytest-dev/pytest#11043
MFC after:	3 weeks
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D41064
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