From 2c7f0d79701976cc68481e6ed23e245e860da2b1 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Tue, 21 Apr 2026 19:08:54 +0100 Subject: [PATCH] nixos-rebuild-ng: mock pathlib.Path.exists in test_upgrade_channels This should avoid make it try to call the real path to see if it exists. Seems to be an issue in a particular setup in aarch64-darwin at least, but I can't reproduce. Fix: #511860. --- pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_nix.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_nix.py b/pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_nix.py index f8c6d75c5290..8fb4d5ef166e 100644 --- a/pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_nix.py +++ b/pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_nix.py @@ -892,11 +892,13 @@ def test_switch_to_configuration_with_systemd_run( ], ) @patch("pathlib.Path.is_dir", autospec=True, return_value=True) +@patch("pathlib.Path.exists", autospec=True, return_value=False) @patch("os.geteuid", autospec=True, return_value=1000) @patch(get_qualified_name(n.run_wrapper, n), autospec=True) def test_upgrade_channels( mock_run: Mock, mock_geteuid: Mock, + mock_exists: Mock, mock_is_dir: Mock, mock_glob: Mock, ) -> None: @@ -912,7 +914,11 @@ def test_upgrade_channels( ["nix-channel", "--update", "nixos"], check=False, sudo=True ) + # root check mock_geteuid.return_value = 0 + # (channel_path / ".update-on-nixos-rebuild").exists() + mock_exists.return_value = True + n.upgrade_channels(all_channels=True, sudo=False) mock_run.assert_has_calls( [