@@ -75,28 +75,37 @@ def does_not_alter_trailing_spaces():
7575
7676def describe_get_block_string_indentation ():
7777 def returns_zero_for_an_empty_list ():
78- assert get_block_string_indentation ([] ) == 0
78+ assert get_block_string_indentation ("" ) == 0
7979
8080 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
8383
8484 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
8888
8989 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
9393
9494 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
100109
101110
102111def describe_print_block_string ():
0 commit comments