4
4
import pytest
5
5
from selfie_lib import expect_selfie
6
6
7
-
8
7
def test_empty_binary_base64 ():
9
8
"""Test base64 encoding of empty byte array"""
10
9
expect_selfie (bytes ()).to_be_base64 ("" )
@@ -21,41 +20,31 @@ def test_large_binary_base64():
21
20
def test_binary_file ():
22
21
"""Test writing binary data to a file"""
23
22
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" )
25
24
26
25
27
26
def test_binary_file_duplicate_equal ():
28
27
"""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" )
41
30
42
31
def test_binary_file_mismatch ():
43
32
"""Test error handling for mismatched binary data"""
44
33
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" )
46
35
47
36
48
37
def test_binary_file_not_found ():
49
38
"""Test error handling for non-existent file"""
50
39
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" )
52
41
assert "no such file" in str (exc_info .value )
53
42
54
43
55
44
def test_base64_mismatch ():
56
45
"""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`"" " )
0 commit comments