1
+ import unicodedata
2
+
1
3
import pytest
2
4
3
5
from conftest import assert_bash_exec , bash_env_saved
4
6
5
7
8
+ def normalize (string ):
9
+ # Applies "canonical decomposition", so might make errors look weird?
10
+ # The alternative is probably `NFC` which composes together some of
11
+ # the characters again.
12
+ # See https://docs.python.org/3/library/unicodedata.html#unicodedata.normalize
13
+ return unicodedata .normalize ("NFD" , string )
14
+
15
+
6
16
@pytest .mark .bashcomp (
7
17
cmd = None ,
8
18
cwd = "_filedir" ,
@@ -22,14 +32,15 @@ def functions(self, bash):
22
32
23
33
def test_match_all (self , bash , functions ):
24
34
output = assert_bash_exec (bash , "__tester '*'" , want_output = True )
25
- assert (
26
- output .strip ()
27
- == "<a b><a$b><a&b><a'b><ab><aé><brackets><dotdot><ext>"
35
+ assert normalize (output .strip ()) == normalize (
36
+ "<a b><a$b><a&b><a'b><ab><aé><brackets><dotdot><ext>"
28
37
)
29
38
30
39
def test_match_pattern (self , bash , functions ):
31
40
output = assert_bash_exec (bash , "__tester 'a*'" , want_output = True )
32
- assert output .strip () == "<a b><a$b><a&b><a'b><ab><aé>"
41
+ assert normalize (output .strip ()) == normalize (
42
+ "<a b><a$b><a&b><a'b><ab><aé>"
43
+ )
33
44
34
45
def test_match_unmatched (self , bash , functions ):
35
46
output = assert_bash_exec (
@@ -51,7 +62,9 @@ def test_protect_from_noglob(self, bash, functions):
51
62
with bash_env_saved (bash , functions ) as bash_env :
52
63
bash_env .set ("noglob" , True )
53
64
output = assert_bash_exec (bash , "__tester 'a*'" , want_output = True )
54
- assert output .strip () == "<a b><a$b><a&b><a'b><ab><aé>"
65
+ assert normalize (output .strip ()) == normalize (
66
+ "<a b><a$b><a&b><a'b><ab><aé>"
67
+ )
55
68
56
69
def test_protect_from_failglob (self , bash , functions ):
57
70
with bash_env_saved (bash ) as bash_env :
@@ -83,4 +96,6 @@ def test_protect_from_GLOBIGNORE(self, bash, functions):
83
96
bash_env .save_shopt ("dotglob" )
84
97
bash_env .write_variable ("GLOBIGNORE" , "*" )
85
98
output = assert_bash_exec (bash , "__tester 'a*'" , want_output = True )
86
- assert output .strip () == "<a b><a$b><a&b><a'b><ab><aé>"
99
+ assert normalize (output .strip ()) == normalize (
100
+ "<a b><a$b><a&b><a'b><ab><aé>"
101
+ )
0 commit comments