From 8af6c62b0bf6a2995115563384e911d8731c1955 Mon Sep 17 00:00:00 2001 From: StillKnotKnown Date: Sat, 7 Feb 2026 15:18:15 +0200 Subject: [PATCH] test: fix platform-specific test failures - test_auth.py: Update regex to expect "Unsupported platform" instead of "Encrypted token decryption" since platform check happens before decryption - test_file_utils.py: Skip test_atomic_write_permission_denied_parent on Windows where chmod doesn't prevent file creation --- tests/core/test_auth.py | 7 ++++--- tests/core/test_file_utils.py | 10 ++++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/tests/core/test_auth.py b/tests/core/test_auth.py index c632e11d..1e07d3ae 100644 --- a/tests/core/test_auth.py +++ b/tests/core/test_auth.py @@ -937,10 +937,11 @@ class TestTokenValidationEdgeCases: valid_token = "enc:0123456789" # This should pass basic length validation - # (will fail later during actual decryption attempt with NotImplementedError) + # (will fail later during actual decryption attempt with ValueError) # Arrange & Act & Assert - # Will fail during platform decryption, not validation - with pytest.raises(ValueError, match="Encrypted token decryption"): + # Will fail during platform check since is_macos is mocked to False + # and platform is not Linux or Windows either + with pytest.raises(ValueError, match="Unsupported platform"): decrypt_token(valid_token) diff --git a/tests/core/test_file_utils.py b/tests/core/test_file_utils.py index f685bbaf..afc1588d 100644 --- a/tests/core/test_file_utils.py +++ b/tests/core/test_file_utils.py @@ -504,13 +504,19 @@ class TestAtomicWriteEdgeCases: def test_atomic_write_permission_denied_parent(self, tmp_path): """Test atomic_write when parent directory is read-only.""" + import sys + import stat + + # Skip on Windows - chmod doesn't prevent file creation + if sys.platform == "win32": + pytest.skip("Directory read-only doesn't prevent file creation on Windows") + # Create a directory and make it read-only ro_dir = tmp_path / "readonly" ro_dir.mkdir() filepath = ro_dir / "test.txt" - # Make directory read-only (skip on Windows where chmod may not work) - import stat + # Make directory read-only (skip on platforms where chmod may not work) try: ro_dir.chmod(stat.S_IRUSR | stat.S_IXUSR) except (OSError, AttributeError):