@@ -1149,6 +1149,66 @@ def testAssertEqualSingleLine(self):
1149
1149
error = str (e ).split ('\n ' , 1 )[1 ]
1150
1150
self .assertEqual (sample_text_error , error )
1151
1151
1152
+ def testAssertEqualwithEmptyString (self ):
1153
+ '''Verify when there is an empty string involved, the diff output
1154
+ does not treat the empty string as a single empty line. It should
1155
+ instead be handled as a non-line.
1156
+ '''
1157
+ sample_text = ''
1158
+ revised_sample_text = 'unladen swallows fly quickly'
1159
+ sample_text_error = '''\
1160
+ + unladen swallows fly quickly
1161
+ '''
1162
+ try :
1163
+ self .assertEqual (sample_text , revised_sample_text )
1164
+ except self .failureException as e :
1165
+ # need to remove the first line of the error message
1166
+ error = str (e ).split ('\n ' , 1 )[1 ]
1167
+ self .assertEqual (sample_text_error , error )
1168
+
1169
+ def testAssertEqualMultipleLinesMissingNewlineTerminator (self ):
1170
+ '''Verifying format of diff output from assertEqual involving strings
1171
+ with multiple lines, but missing the terminating newline on both.
1172
+ '''
1173
+ sample_text = 'laden swallows\n fly sloely'
1174
+ revised_sample_text = 'laden swallows\n fly slowly'
1175
+ sample_text_error = '''\
1176
+ laden swallows
1177
+ - fly sloely
1178
+ ? ^
1179
+ + fly slowly
1180
+ ? ^
1181
+ '''
1182
+ try :
1183
+ self .assertEqual (sample_text , revised_sample_text )
1184
+ except self .failureException as e :
1185
+ # need to remove the first line of the error message
1186
+ error = str (e ).split ('\n ' , 1 )[1 ]
1187
+ self .assertEqual (sample_text_error , error )
1188
+
1189
+ def testAssertEqualMultipleLinesMismatchedNewlinesTerminators (self ):
1190
+ '''Verifying format of diff output from assertEqual involving strings
1191
+ with multiple lines and mismatched newlines. The output should
1192
+ include a - on it's own line to indicate the newline difference
1193
+ between the two strings
1194
+ '''
1195
+ sample_text = 'laden swallows\n fly sloely\n '
1196
+ revised_sample_text = 'laden swallows\n fly slowly'
1197
+ sample_text_error = '''\
1198
+ laden swallows
1199
+ - fly sloely
1200
+ ? ^
1201
+ + fly slowly
1202
+ ? ^
1203
+ -\x20
1204
+ '''
1205
+ try :
1206
+ self .assertEqual (sample_text , revised_sample_text )
1207
+ except self .failureException as e :
1208
+ # need to remove the first line of the error message
1209
+ error = str (e ).split ('\n ' , 1 )[1 ]
1210
+ self .assertEqual (sample_text_error , error )
1211
+
1152
1212
def testEqualityBytesWarning (self ):
1153
1213
if sys .flags .bytes_warning :
1154
1214
def bytes_warning ():
0 commit comments