Repository navigation
Description
#19636 was my starting point, but I'm starting to see a problem that's actually a bug and a regression as compared to the 7.2.x branch, so I'm opening this to separate concerns.
There are currently 4 tests failing (some of which are not brand new) on main if pytest is run with HOME= pytest <...>, and the number goes up to 20 with the following patch, which prevent a fixture to mock $HOME if not already defined.
diff --git a/astropy/conftest.py b/astropy/conftest.py
index fd8267156a..cda809e3f9 100644
--- a/astropy/conftest.py
+++ b/astropy/conftest.py
@@ -83,15 +83,15 @@ def ignore_config_paths_global_state(monkeypatch, tmp_path_factory):
"config",
pristine_config_finder,
)
+ if os.getenv("HOME") is not None:
+ # also mock $HOME as it's part of the global state taken into account
+ # for path detection
+ mock_home_dir = tmp_path_factory.mktemp("MOCK_HOME")
- # also mock $HOME as it's part of the global state taken into account
- # for path detection
- mock_home_dir = tmp_path_factory.mktemp("MOCK_HOME")
+ def mock_home():
+ return mock_home_dir
- def mock_home():
- return mock_home_dir
-
- monkeypatch.setattr(Path, "home", mock_home)
+ monkeypatch.setattr(Path, "home", mock_home)
yieldIn contrast, I see no failure on 7.2.x, so this is almost certainly a regression (and definitely an oversight) from #19575
I don't think this is blocking for a beta, but it will be blocking for a rc. I don't think it'll be too difficult to fix, though I do need to take a minute to think it through. In particular, I was surprised to discover that pathlib.Path.home() usually returns the expected path even if HOME isn't set, which might be the origin of some inconsistency in my logic.
I'm assigning myself since it's so clearly up my alley, but this by no means imply that help is unwanted, if anyone wants to participate to the resolution.
Activity
[-]BUG: 20 test failures when unsetting the HOME env var.[/-][+]BUG: 20 test failures when unsetting the HOME env var[/+]pllim commentedon May 5, 2026
In what real world situation would someone unset HOME?
neutrinoceros commentedon May 5, 2026
The actual use case is that some systems might not define it at all. In any case this was explicitly supported (even though untested) in previous version so I don't want to introduce a subtly broken revision without careful inquiry.
neutrinoceros commentedon May 8, 2026
Update: 0 tests failing on main without the patch above, and only one with it:
test_env_variables_missing_subdir_and_default(depending on the presence of a file). This one test should monkeypatchPath.homeitself.pllim commentedon May 8, 2026
Looking at #19712 , you have decided that this is only a testing problem after all, not a production bug?
neutrinoceros commentedon May 8, 2026
not really, it's just that every other failure point already went away as I fixed other aspects of the new system. #19712 fixes the only remaining problems.
pllim commentedon May 8, 2026
For future reference, exactly with other PR fixed the actual bug reported here?
neutrinoceros commentedon May 8, 2026
I don't know for sure, this was an unexpected result, and looking back at the recent merger doesn't yield any obvious answer.