Skip to content

Commit 20588e8

Browse files
committed
test(verifier): replace sed calls with native Python code (#157)
On macOS, `sed -i -e` creates backup files with `-e` suffix, causing test failures due to unexpected files in the test directory. This commit replaces `sed` commands with native Python file operations for better platform independence of tests.
1 parent 16af0d0 commit 20588e8

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

tests/test_verifier.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,10 @@ def test_get_file_info_local_good_input_wrong_checksum():
124124
assert test_result.output.endswith("\n==> Success!\n")
125125

126126
# simulate checksum change
127-
cmd = "sed -i -e 's,a,b,g' {}".format(test_file)
128-
subprocess.check_output(cmd, shell=True)
127+
with open(test_file, "r") as f:
128+
content = f.read()
129+
with open(test_file, "w") as f:
130+
f.write(content.replace("a", "b"))
129131

130132
# now test verifier
131133
test_verifier_files = CliRunner()
@@ -153,9 +155,11 @@ def test_get_file_info_local_good_input_wrong_size():
153155
assert os.path.getsize(test_file) == 3644
154156
assert test_result.output.endswith("\n==> Success!\n")
155157

156-
# simulate checksum change
157-
cmd = "sed -i -e 's,a,bbbbbb,g' {}".format(test_file)
158-
subprocess.check_output(cmd, shell=True)
158+
# simulate size change
159+
with open(test_file, "r") as f:
160+
content = f.read()
161+
with open(test_file, "w") as f:
162+
f.write(content.replace("a", "bbbbbb"))
159163

160164
# now test verifier
161165
test_verifier_files = CliRunner()

0 commit comments

Comments
 (0)