@@ -75,28 +75,37 @@ def does_not_alter_trailing_spaces():
75
75
76
76
def describe_get_block_string_indentation ():
77
77
def returns_zero_for_an_empty_list ():
78
- assert get_block_string_indentation ([] ) == 0
78
+ assert get_block_string_indentation ("" ) == 0
79
79
80
80
def do_not_take_first_line_into_account ():
81
- assert get_block_string_indentation ([ " a" ] ) == 0
82
- assert get_block_string_indentation ([ " a" , " b" ] ) == 2
81
+ assert get_block_string_indentation (" a" ) == 0
82
+ assert get_block_string_indentation (" a\n b" ) == 2
83
83
84
84
def returns_minimal_indentation_length ():
85
- assert get_block_string_indentation ([ "" , " a" , " b" ] ) == 1
86
- assert get_block_string_indentation ([ "" , " a" , " b" ] ) == 1
87
- assert get_block_string_indentation ([ "" , " a" , " b" , "c" ] ) == 0
85
+ assert get_block_string_indentation (" \n a \n b" ) == 1
86
+ assert get_block_string_indentation (" \n a \n b" ) == 1
87
+ assert get_block_string_indentation (" \n a \n b \n c" ) == 0
88
88
89
89
def count_both_tab_and_space_as_single_character ():
90
- assert get_block_string_indentation ([ "" , " \t a" , " b" ] ) == 1
91
- assert get_block_string_indentation ([ "" , " \ t a" , " b" ] ) == 2
92
- assert get_block_string_indentation ([ "" , " \t a" , " b" ] ) == 3
90
+ assert get_block_string_indentation (" \n \t a \n b" ) == 1
91
+ assert get_block_string_indentation (" \n \ t a\n b" ) == 2
92
+ assert get_block_string_indentation (" \n \t a\n b" ) == 3
93
93
94
94
def do_not_take_empty_lines_into_account ():
95
- assert get_block_string_indentation ((["a" , "\t " ])) == 0
96
- assert get_block_string_indentation ((["a" , " " ])) == 0
97
- assert get_block_string_indentation ((["a" , " " , " b" ])) == 2
98
- assert get_block_string_indentation ((["a" , " " , " b" ])) == 2
99
- assert get_block_string_indentation ((["a" , "" , " b" ])) == 1
95
+ assert get_block_string_indentation ("a\n " ) == 0
96
+ assert get_block_string_indentation ("a\n \t " ) == 0
97
+ assert get_block_string_indentation ("a\n \n b" ) == 1
98
+ assert get_block_string_indentation ("a\n \n b" ) == 2
99
+
100
+ def treat_carriage_returns_like_newlines ():
101
+ assert get_block_string_indentation (" a\r b" ) == 2
102
+ assert get_block_string_indentation (" a\r \n b" ) == 2
103
+ assert get_block_string_indentation ("\r a\r b" ) == 1
104
+ assert get_block_string_indentation ("\r \n a\r \n b" ) == 1
105
+ assert get_block_string_indentation ("\r \t a\r b" ) == 3
106
+ assert get_block_string_indentation ("\r \n \t a\r \n b" ) == 3
107
+ assert get_block_string_indentation ("a\r \r b" ) == 2
108
+ assert get_block_string_indentation ("a\r \n \r \n b" ) == 2
100
109
101
110
102
111
def describe_print_block_string ():
0 commit comments