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