From 7f7a251440c80922565aa3c32c35933567b4efda Mon Sep 17 00:00:00 2001 From: Zoheb Shaikh Date: Fri, 24 Jan 2025 10:40:43 +0000 Subject: [PATCH] Hotfix: Add patch instead of creating inaccessible file path in test (#800) closes #799 --- tests/unit_tests/test_cli.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/unit_tests/test_cli.py b/tests/unit_tests/test_cli.py index d9738bc4a..7a68ca955 100644 --- a/tests/unit_tests/test_cli.py +++ b/tests/unit_tests/test_cli.py @@ -784,13 +784,11 @@ def test_wrapper_permission_error( runner: CliRunner, mock_authn_server: responses.RequestsMock, tmp_path ): token_file: Path = tmp_path / "dir/token" - token_file.parent.mkdir() - # Change the dir permissions to read-only - (tmp_path / "dir").chmod(0o400) config: ApplicationConfig = ApplicationConfig(auth_token_path=token_file) config_path = tmp_path / "config.yaml" with open(config_path, mode="w") as valid_auth_config_file: valid_auth_config_file.write(yaml.dump(config.model_dump())) - result = runner.invoke(main, ["-c", config_path.as_posix(), "login"]) + with patch.object(Path, "write_text", side_effect=PermissionError): + result = runner.invoke(main, ["-c", config_path.as_posix(), "login"]) assert f"Permission denied: Cannot write to {token_file}\n" == result.stdout