Skip to content

Commit ec4c207

Browse files
committed
Cleanup the the binary_test stuff.
1 parent 43da71d commit ec4c207

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

python/example-pytest-selfie/tests/binary_test.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,20 @@ def test_binary_file():
2424
expect_selfie(data).to_be_file("test_binary.bin")
2525

2626

27-
def test_binary_file_duplicate():
27+
def test_binary_file_duplicate_equal():
2828
"""Test writing same binary data to a file multiple times"""
29-
data = b"same data"
30-
expect_selfie(data).to_be_file("duplicate.bin")
31-
expect_selfie(data).to_be_file("duplicate.bin")
29+
expect_selfie(b"equal").to_be_file("duplicate_equal.bin")
30+
expect_selfie(b"equal").to_be_file("duplicate_equal.bin")
3231

32+
def test_binary_file_duplicate_unequal():
33+
"""Test writing same binary data to a file multiple times"""
34+
try:
35+
expect_selfie(b"a").to_be_file("duplicate_unequal.bin")
36+
expect_selfie(b"b").to_be_file("duplicate_unequal.bin")
37+
except AssertionError as e:
38+
expect_selfie(str(e)).to_be("""Snapshot mismatch, TODO: string comparison
39+
- update this snapshot by adding `_TODO` to the function name
40+
- update all snapshots in this file by adding """)
3341

3442
def test_binary_file_mismatch():
3543
"""Test error handling for mismatched binary data"""
@@ -48,16 +56,6 @@ def test_base64_mismatch():
4856
"""Test error handling for mismatched base64 data"""
4957
data = b"test data"
5058
encoded = base64.b64encode(b"different data").decode()
51-
with pytest.raises(AssertionError):
52-
expect_selfie(data).to_be_base64(encoded)
53-
54-
55-
def test_readonly_mode_todo():
56-
"""Test error handling in readonly mode for TODO methods"""
57-
from selfie_lib import _selfieSystem
58-
59-
print(f"Current mode: {_selfieSystem().mode}")
60-
print(f"SELFIE env var: {os.getenv('SELFIE')}")
6159
with pytest.raises(AssertionError) as exc_info:
62-
expect_selfie(b"test").to_be_base64_TODO()
63-
assert "readonly mode" in str(exc_info.value).lower()
60+
expect_selfie(data).to_be_base64("dGVzdCBkYXRh")
61+
expect_selfie(str(exc_info.value)).to_be_TODO("Error while parsing the literal at File: /Users/ntwigg/Documents/dev/selfie/python/example-pytest-selfie/tests/binary_test.py, Line: 60. Please report this error at https://github.com/diffplug/selfie")

0 commit comments

Comments
 (0)