@@ -21,6 +21,10 @@ def test_triple_single_quotes_work_too(self):
2121 string = '''Bonjour tout le monde!'''
2222 self .assertEqual (__ , isinstance (string , str ))
2323
24+ def test_raw_strings_are_also_strings (self ):
25+ string = r"Konnichi wa, world!"
26+ self .assertEqual (__ , isinstance (string , str ))
27+
2428 def test_use_single_quotes_to_create_string_with_double_quotes (self ):
2529 string = 'He said, "Go Away."'
2630 self .assertEqual (__ , string )
@@ -57,7 +61,11 @@ 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 )
60-
64+
65+ def test_adjacent_strings_are_concatenated_automatically (self ):
66+ string = "Hello" ", " "World"
67+ self .assertEqual (__ , string )
68+
6169 def test_plus_will_not_modify_original_strings (self ):
6270 hi = "Hello, "
6371 there = "world"
@@ -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 .assertListEqual ([__ , __ , __ , __ ], 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
149+
150+ # Useful in regular expressions, file paths, URLs, etc.
143151
144152 def test_strings_can_be_joined (self ):
145153 words = ["Now" , "is" , "the" , "time" ]
146154 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