@@ -91,71 +91,3 @@ def test_most_strings_interpret_escape_characters(self):
9191 self .assertEqual ('\n ' , string )
9292 self .assertEqual ("""\n """ , string )
9393 self .assertEqual (__ , len (string ))
94-
95- def test_use_format_to_interpolate_variables (self ):
96- value1 = 'one'
97- value2 = 2
98- string = "The values are {0} and {1}" .format (value1 , value2 )
99- self .assertEqual (__ , string )
100-
101- def test_formatted_values_con_be_shown_in_any_order_or_be_repeated (self ):
102- value1 = 'doh'
103- value2 = 'DOH'
104- string = "The values are {1}, {0}, {0} and {1}!" .format (value1 , value2 )
105- self .assertEqual (__ , string )
106-
107- def test_any_python_expression_may_be_interpolated (self ):
108- import math # import a standard python module with math functions
109-
110- decimal_places = 4
111- string = "The square root of 5 is {0:.{1}f}" .format (math .sqrt (5 ), \
112- decimal_places )
113- self .assertEqual (__ , string )
114-
115- def test_you_can_get_a_substring_from_a_string (self ):
116- string = "Bacon, lettuce and tomato"
117- self .assertEqual (__ , string [7 :10 ])
118-
119- def test_you_can_get_a_single_character_from_a_string (self ):
120- string = "Bacon, lettuce and tomato"
121- self .assertEqual (__ , string [1 ])
122-
123- def test_single_characters_can_be_represented_by_integers (self ):
124- self .assertEqual (__ , ord ('a' ))
125- self .assertEqual (__ , ord ('b' ) == (ord ('a' ) + 1 ))
126-
127- def test_strings_can_be_split (self ):
128- string = "Sausage Egg Cheese"
129- words = string .split ()
130- self .assertListEqual ([__ , __ , __ ], words )
131-
132- def test_strings_can_be_split_with_different_patterns (self ):
133- import re #import python regular expression library
134-
135- string = "the,rain;in,spain"
136- pattern = re .compile (',|;' )
137-
138- words = pattern .split (string )
139-
140- self .assertListEqual ([__ , __ , __ , __ ], words )
141-
142- # Pattern is a Python regular expression pattern which matches ',' or ';'
143-
144- def test_raw_strings_do_not_interpret_escape_characters (self ):
145- string = r'\n'
146- self .assertNotEqual ('\n ' , string )
147- self .assertEqual (__ , string )
148- self .assertEqual (__ , len (string ))
149-
150- # Useful in regular expressions, file paths, URLs, etc.
151-
152- def test_strings_can_be_joined (self ):
153- words = ["Now" , "is" , "the" , "time" ]
154- self .assertEqual (__ , ' ' .join (words ))
155-
156- def test_strings_can_change_case (self ):
157- self .assertEqual (__ , 'guido' .capitalize ())
158- self .assertEqual (__ , 'guido' .upper ())
159- self .assertEqual (__ , 'TimBot' .lower ())
160- self .assertEqual (__ , 'guido van rossum' .title ())
161- self .assertEqual (__ , 'ToTaLlY aWeSoMe' .swapcase ())
0 commit comments