Skip to content

Commit 597f157

Browse files
committed
I would expect this to pass.
1 parent 2150adc commit 597f157

File tree

4 files changed

+13
-21
lines changed

4 files changed

+13
-21
lines changed

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

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import pytest
55
from selfie_lib import expect_selfie
66

7-
87
def test_empty_binary_base64():
98
"""Test base64 encoding of empty byte array"""
109
expect_selfie(bytes()).to_be_base64("")
@@ -21,41 +20,31 @@ def test_large_binary_base64():
2120
def test_binary_file():
2221
"""Test writing binary data to a file"""
2322
data = b"test binary data"
24-
expect_selfie(data).to_be_file("test_binary.bin")
23+
expect_selfie(data).to_be_file("tests/binary_test__test_binary_file.bin")
2524

2625

2726
def test_binary_file_duplicate_equal():
2827
"""Test writing same binary data to a file multiple times"""
29-
expect_selfie(b"equal").to_be_file("duplicate_equal.bin")
30-
expect_selfie(b"equal").to_be_file("duplicate_equal.bin")
31-
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 """)
28+
expect_selfie(b"equal").to_be_file("tests/binary_test__test_binary_file_duplicate_equal.bin")
29+
expect_selfie(b"equal").to_be_file("tests/binary_test__test_binary_file_duplicate_equal.bin")
4130

4231
def test_binary_file_mismatch():
4332
"""Test error handling for mismatched binary data"""
4433
with pytest.raises(AssertionError):
45-
expect_selfie(b"different").to_be_file("test_binary.bin")
34+
expect_selfie(b"different").to_be_file("tests/binary_test__SHOULD_NOT_EXIST.bin")
4635

4736

4837
def test_binary_file_not_found():
4938
"""Test error handling for non-existent file"""
5039
with pytest.raises(AssertionError) as exc_info:
51-
expect_selfie(b"test").to_be_file("nonexistent.bin")
40+
expect_selfie(b"test").to_be_file("tests/binary_test__SHOULD_NOT_EXIST.bin")
5241
assert "no such file" in str(exc_info.value)
5342

5443

5544
def test_base64_mismatch():
5645
"""Test error handling for mismatched base64 data"""
57-
data = b"test data"
58-
encoded = base64.b64encode(b"different data").decode()
59-
with pytest.raises(AssertionError) as exc_info:
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")
46+
with pytest.raises(Exception) as exc_info:
47+
expect_selfie(b"test data").to_be_base64("AAAA")
48+
expect_selfie(str(exc_info.value)).to_be("""Snapshot mismatch, TODO: string comparison
49+
- update this snapshot by adding `_TODO` to the function name
50+
- update all snapshots in this file by adding `#selfieonce` or `#SELFIEWRITE`""")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test binary data
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
equal
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
a

0 commit comments

Comments
 (0)