Skip to content

Commit

Permalink
chore: write bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
gg-mmill committed Dec 9, 2024
1 parent 91226c6 commit bb30607
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tests/unit/cmd/scan/test_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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"):
Expand All @@ -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}"
Expand All @@ -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"):
Expand Down Expand Up @@ -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"]
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit bb30607

Please sign in to comment.