From 86e3302381f25397802a29d65ae54676f5fbedfc Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Wed, 21 May 2025 12:26:46 +0100 Subject: [PATCH] nixos-rebuild-ng: avoid get_qualified_name usage for pathlib.Path Seems to be broken since Python 3.13. --- .../ni/nixos-rebuild-ng/src/tests/test_main.py | 4 ++-- .../ni/nixos-rebuild-ng/src/tests/test_models.py | 14 +++++++------- .../ni/nixos-rebuild-ng/src/tests/test_nix.py | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_main.py b/pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_main.py index db21ddd9d64a..f218311cf63d 100644 --- a/pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_main.py +++ b/pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_main.py @@ -1083,8 +1083,8 @@ def test_execute_test_flake(mock_run: Mock, tmp_path: Path) -> None: @patch(get_qualified_name(nr.process.subprocess.run), autospec=True) -@patch(get_qualified_name(nr.nix.Path.exists, nr.nix), autospec=True, return_value=True) -@patch(get_qualified_name(nr.nix.Path.mkdir, nr.nix), autospec=True) +@patch("pathlib.Path.exists", autospec=True, return_value=True) +@patch("pathlib.Path.mkdir", autospec=True) def test_execute_test_rollback( mock_path_mkdir: Mock, mock_path_exists: Mock, diff --git a/pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_models.py b/pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_models.py index 6d2017392fbf..0bbe42d3291b 100644 --- a/pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_models.py +++ b/pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_models.py @@ -100,7 +100,7 @@ def test_flake_from_arg( # None when we do not have /etc/nixos/flake.nix with patch( - get_qualified_name(m.Path.exists, m), + "pathlib.Path.exists", autospec=True, return_value=False, ): @@ -109,12 +109,12 @@ def test_flake_from_arg( # None when we have a file in /etc/nixos/flake.nix with ( patch( - get_qualified_name(m.Path.exists, m), + "pathlib.Path.exists", autospec=True, return_value=True, ), patch( - get_qualified_name(m.Path.is_symlink, m), + "pathlib.Path.is_symlink", autospec=True, return_value=False, ), @@ -130,17 +130,17 @@ def test_flake_from_arg( with ( patch( - get_qualified_name(m.Path.exists, m), + "pathlib.Path.exists", autospec=True, return_value=True, ), patch( - get_qualified_name(m.Path.is_symlink, m), + "pathlib.Path.is_symlink", autospec=True, return_value=True, ), patch( - get_qualified_name(m.Path.resolve, m), + "pathlib.Path.resolve", autospec=True, return_value=Path("/path/to/flake.nix"), ), @@ -161,7 +161,7 @@ def test_flake_from_arg( ) -@patch(get_qualified_name(m.Path.mkdir, m), autospec=True) +@patch("pathlib.Path.mkdir", autospec=True) def test_profile_from_arg(mock_mkdir: Mock) -> None: assert m.Profile.from_arg("system") == m.Profile( "system", 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 a6fac1c6de1e..9a30c0dce011 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 @@ -809,7 +809,7 @@ def test_switch_to_configuration_with_systemd_run( @patch( - get_qualified_name(n.Path.glob, n), + "pathlib.Path.glob", autospec=True, return_value=[ Path("/nix/var/nix/profiles/per-user/root/channels/nixos"), @@ -817,7 +817,7 @@ def test_switch_to_configuration_with_systemd_run( Path("/nix/var/nix/profiles/per-user/root/channels/home-manager"), ], ) -@patch(get_qualified_name(n.Path.is_dir, n), autospec=True, return_value=True) +@patch("pathlib.Path.is_dir", autospec=True, return_value=True) def test_upgrade_channels(mock_is_dir: Mock, mock_glob: Mock) -> None: with patch(get_qualified_name(n.run_wrapper, n), autospec=True) as mock_run: n.upgrade_channels(False)