1
1
from __future__ import annotations
2
2
3
+ import re
3
4
import unittest
4
5
from pathlib import Path
5
6
from unittest .mock import call
@@ -20,8 +21,8 @@ def test_utf32_bom_le(tmpdir):
20
21
b'\x86 \x98 \xe3 \x86 \x92 \xe3 \x86 \x9d ' ,
21
22
)
22
23
assert no_boms .main ((str (f ),)) == 13
23
- assert call ( ' bom32le.txt: has a UTF-32 BOM (LE)' ) \
24
- in mocked_print .mock_calls
24
+ assert re . match ( r'^.*[\\/] bom32le\ .txt: has a UTF-32 BOM \ (LE\)$' ,
25
+ mocked_print .call_args . args [ 0 ]) is not None
25
26
26
27
27
28
def test_utf32_bom_be (tmpdir ):
@@ -37,8 +38,8 @@ def test_utf32_bom_be(tmpdir):
37
38
b'\x86 \x98 \xe3 \x86 \x92 \xe3 \x86 \x9d ' ,
38
39
)
39
40
assert no_boms .main ((str (f ),)) == 11
40
- assert call ( ' bom32be.txt: has a UTF-32 BOM (BE)' ) \
41
- in mocked_print .mock_calls
41
+ assert re . match ( r'^.*[\\/] bom32be\ .txt: has a UTF-32 BOM \ (BE\)$' ,
42
+ mocked_print .call_args . args [ 0 ]) is not None
42
43
43
44
44
45
def test_utf16_bom_le (tmpdir ):
@@ -54,8 +55,8 @@ def test_utf16_bom_le(tmpdir):
54
55
b'\x86 \x98 \xe3 \x86 \x92 \xe3 \x86 \x9d ' ,
55
56
)
56
57
assert no_boms .main ((str (f ),)) == 7
57
- assert call ( ' bom16le.txt: has a UTF-16 BOM (LE)' ) \
58
- in mocked_print .mock_calls
58
+ assert re . match ( r'^.*[\\/] bom16le\ .txt: has a UTF-16 BOM \ (LE\)$' ,
59
+ mocked_print .call_args . args [ 0 ]) is not None
59
60
60
61
61
62
def test_utf16_bom_be (tmpdir ):
@@ -71,8 +72,8 @@ def test_utf16_bom_be(tmpdir):
71
72
b'\x86 \x98 \xe3 \x86 \x92 \xe3 \x86 \x9d ' ,
72
73
)
73
74
assert no_boms .main ((str (f ),)) == 5
74
- assert call ( ' bom16be.txt: has a UTF-16 BOM (BE)' ) \
75
- in mocked_print .mock_calls
75
+ assert re . match ( r'^.*[\\/] bom16be\ .txt: has a UTF-16 BOM \ (BE\)$' ,
76
+ mocked_print .call_args . args [ 0 ]) is not None
76
77
77
78
78
79
def test_utf8_bom_directly (tmpdir ):
@@ -88,8 +89,8 @@ def test_utf8_bom_directly(tmpdir):
88
89
b'\x86 \x98 \xe3 \x86 \x92 \xe3 \x86 \x9d ' ,
89
90
)
90
91
assert no_boms .main ((str (f ),)) == 3
91
- assert call ( ' bom8.txt: has a UTF-8 BOM' ) \
92
- in mocked_print .mock_calls
92
+ assert re . match ( r'^.*[\\/] bom8\ .txt: has a UTF-8 BOM$' ,
93
+ mocked_print .call_args . args [ 0 ]) is not None
93
94
94
95
95
96
def test_utf8_bom_via_encoding (tmpdir ):
0 commit comments