1
1
from selfie_lib import EscapeLeadingWhitespace
2
2
3
+
3
4
def test_detection ():
4
5
# not enough to detect
5
6
assert EscapeLeadingWhitespace .appropriate_for ("" ) == EscapeLeadingWhitespace .ALWAYS
6
- assert EscapeLeadingWhitespace .appropriate_for ("abc" ) == EscapeLeadingWhitespace .ALWAYS
7
- assert EscapeLeadingWhitespace .appropriate_for ("abc\n abc" ) == EscapeLeadingWhitespace .ALWAYS
7
+ assert (
8
+ EscapeLeadingWhitespace .appropriate_for ("abc" ) == EscapeLeadingWhitespace .ALWAYS
9
+ )
10
+ assert (
11
+ EscapeLeadingWhitespace .appropriate_for ("abc\n abc" )
12
+ == EscapeLeadingWhitespace .ALWAYS
13
+ )
8
14
9
15
# all spaces -> only tabs need escape
10
- assert EscapeLeadingWhitespace .appropriate_for (" " ) == EscapeLeadingWhitespace .ONLY_ON_TAB
11
- assert EscapeLeadingWhitespace .appropriate_for (" " ) == EscapeLeadingWhitespace .ONLY_ON_TAB
12
- assert EscapeLeadingWhitespace .appropriate_for (" \n " ) == EscapeLeadingWhitespace .ONLY_ON_TAB
16
+ assert (
17
+ EscapeLeadingWhitespace .appropriate_for (" " ) == EscapeLeadingWhitespace .ALWAYS
18
+ )
19
+ assert (
20
+ EscapeLeadingWhitespace .appropriate_for (" " )
21
+ == EscapeLeadingWhitespace .ONLY_ON_TAB
22
+ )
23
+ assert (
24
+ EscapeLeadingWhitespace .appropriate_for (" \n " )
25
+ == EscapeLeadingWhitespace .ONLY_ON_TAB
26
+ )
13
27
14
28
# all tabs -> only space needs escape
15
- assert EscapeLeadingWhitespace .appropriate_for ("\t " ) == EscapeLeadingWhitespace .ONLY_ON_SPACE
16
- assert EscapeLeadingWhitespace .appropriate_for ("\t \t " ) == EscapeLeadingWhitespace .ONLY_ON_SPACE
17
- assert EscapeLeadingWhitespace .appropriate_for ("\t \n \t " ) == EscapeLeadingWhitespace .ONLY_ON_SPACE
29
+ assert (
30
+ EscapeLeadingWhitespace .appropriate_for ("\t " )
31
+ == EscapeLeadingWhitespace .ONLY_ON_SPACE
32
+ )
33
+ assert (
34
+ EscapeLeadingWhitespace .appropriate_for ("\t \t " )
35
+ == EscapeLeadingWhitespace .ONLY_ON_SPACE
36
+ )
37
+ assert (
38
+ EscapeLeadingWhitespace .appropriate_for ("\t \n \t " )
39
+ == EscapeLeadingWhitespace .ONLY_ON_SPACE
40
+ )
18
41
19
42
# it's a mess -> everything needs escape
20
- assert EscapeLeadingWhitespace .appropriate_for ("\t \n " ) == EscapeLeadingWhitespace .ALWAYS
43
+ assert (
44
+ EscapeLeadingWhitespace .appropriate_for ("\t \n " )
45
+ == EscapeLeadingWhitespace .ALWAYS
46
+ )
21
47
22
48
# single spaces and tabs -> only tabs need escape
23
- test_string = """/*
49
+ test_string = f """/*
24
50
* Copyright
25
51
*/
26
- interface Foo {
27
- \t fun bar()
28
- }"""
29
- assert EscapeLeadingWhitespace .appropriate_for (test_string ) == EscapeLeadingWhitespace .ALWAYS
52
+ interface Foo [
53
+ { '\t ' } bar()
54
+ ]"""
55
+ assert (
56
+ EscapeLeadingWhitespace .appropriate_for (test_string )
57
+ == EscapeLeadingWhitespace .ALWAYS
58
+ )
0 commit comments