@@ -17,6 +17,10 @@ def test_triple_quote_strings_are_also_strings(self):
1717 string = """Howdy, world!"""
1818 self .assertEqual (__ , isinstance (string , basestring ))
1919
20+ def test_raw_strings_are_also_strings (self ):
21+ string = r"Konnichi wa, world!"
22+ self .assertEqual (__ , isinstance (string , basestring ))
23+
2024 def test_triple_single_quotes_work_too (self ):
2125 string = '''Bonjour tout le monde!'''
2226 self .assertEqual (__ , isinstance (string , basestring ))
@@ -57,6 +61,10 @@ def but_you_still_have_to_be_careful_at_the_end_of_a_triple_quoted_string(self):
5761 def test_plus_concatenates_strings (self ):
5862 string = "Hello, " + "world"
5963 self .assertEqual (__ , string )
64+
65+ def test_adjacent_strings_are_concatenated_automatically (self ):
66+ string = "Hello" ", " "World"
67+ self .assertEqual (__ , string )
6068
6169 def test_plus_will_not_modify_original_strings (self ):
6270 hi = "Hello, "
@@ -125,22 +133,29 @@ def test_strings_can_be_split_with_different_patterns(self):
125133 import re #import python regular expression library
126134
127135 string = "the,rain;in,spain"
128- pattern = re .compile (r ',|;' )
136+ pattern = re .compile (',|;' )
129137
130138 words = pattern .split (string )
131139
132140 self .assertEqual ([__ , __ , __ , __ ], words )
133141
134142 # Pattern is a Python regular expression pattern which matches ',' or ';'
135143
136- def test_regular_expression_strings_do_not_interpret_escape_characters (self ):
144+ def test_raw_strings_do_not_interpret_escape_characters (self ):
137145 string = r'\n'
138146 self .assertNotEqual ('\n ' , string )
139147 self .assertEqual (__ , string )
140148 self .assertEqual (__ , len (string ))
141-
142- # This is to make patterns easier to read
143-
149+
150+ # Useful in regular expressions, file paths, URLs, etc.
151+
144152 def test_strings_can_be_joined (self ):
145153 words = ["Now" , "is" , "the" , "time" ]
146- self .assertEqual (__ , ' ' .join (words ))
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