diff --git a/tests/unit/cmd/scan/test_path.py b/tests/unit/cmd/scan/test_path.py index cdf99db045..4da22f50b0 100644 --- a/tests/unit/cmd/scan/test_path.py +++ b/tests/unit/cmd/scan/test_path.py @@ -58,7 +58,7 @@ def test_scan_file_secret(self, cli_fs_runner): THEN the secret is reported AND the exit code is not 0 """ - Path("file_secret").write_text(UNCHECKED_SECRET_PATCH) + Path("file_secret").write_bytes(UNCHECKED_SECRET_PATCH.encode()) assert os.path.isfile("file_secret") cmd = ["secret", "scan", "path", "file_secret"] @@ -79,7 +79,7 @@ def test_scan_file_secret(self, cli_fs_runner): ) def test_scan_file_secret_with_validity(self, cli_fs_runner): - Path("file_secret").write_text(VALID_SECRET_PATCH) + Path("file_secret").write_bytes(VALID_SECRET_PATCH.encode()) assert os.path.isfile("file_secret") with my_vcr.use_cassette("test_scan_path_file_secret_with_validity"): @@ -102,7 +102,7 @@ def test_scan_file_secret_with_validity(self, cli_fs_runner): @pytest.mark.parametrize("validity", [True, False]) def test_scan_file_secret_json_with_validity(self, cli_fs_runner, validity): secret = VALID_SECRET_PATCH if validity else UNCHECKED_SECRET_PATCH - Path("file_secret").write_text(secret) + Path("file_secret").write_bytes(secret.encode()) assert os.path.isfile("file_secret") cassette_name = f"test_scan_file_secret-{validity}" @@ -122,7 +122,7 @@ def test_scan_file_secret_json_with_validity(self, cli_fs_runner, validity): @pytest.mark.parametrize("json_output", [False, True]) def test_scan_file_secret_exit_zero(self, cli_fs_runner, json_output): - Path("file_secret").write_text(UNCHECKED_SECRET_PATCH) + Path("file_secret").write_bytes(UNCHECKED_SECRET_PATCH.encode()) assert os.path.isfile("file_secret") with my_vcr.use_cassette("test_scan_file_secret"): @@ -207,7 +207,7 @@ def test_scan_ignored_file(self, scan_mock, cli_fs_runner): - "file1" """ - Path(".gitguardian.yaml").write_text(config) + Path(".gitguardian.yaml").write_bytes(config.encode()) result = cli_fs_runner.invoke( cli, ["secret", "scan", "path", "file1", "file2", "-y"] @@ -415,8 +415,8 @@ def test_scan_path_use_gitignore( # files in repo ignored_secret = local_repo.path / "ignored_file_secret" found_secret = local_repo.path / "found_file_secret" - ignored_secret.write_text(VALID_SECRET_PATCH) - found_secret.write_text(VALID_SECRET_PATCH) + ignored_secret.write_bytes(VALID_SECRET_PATCH.encode()) + found_secret.write_bytes(VALID_SECRET_PATCH.encode()) gitignore = local_repo.path / ".gitignore" gitignore.write_text("ignored_file_secret") @@ -478,7 +478,7 @@ def test_scan_path_use_gitignore( def test_ignore_detectors( self, cli_fs_runner, ignored_detectors, nb_secret, nb_ignored, all_secrets ): - Path("file_secret").write_text(_ONE_LINE_AND_MULTILINE_PATCH) + Path("file_secret").write_bytes(_ONE_LINE_AND_MULTILINE_PATCH.encode()) all_secrets_option = ["--all-secrets"] if all_secrets else [] with my_vcr.use_cassette("test_scan_path_file_one_line_and_multiline_patch"): result = cli_fs_runner.invoke(