@@ -210,8 +210,8 @@ def test_make_boundary(self):
210210 self .assertEqual (msg .items ()[0 ][1 ], 'multipart/form-data' )
211211 # Trigger creation of boundary
212212 msg .as_string ()
213- self .assertEqual (msg .items ()[0 ][1 ][: 33 ],
214- 'multipart/form-data; boundary="==' )
213+ self .assertStartsWith (msg .items ()[0 ][1 ],
214+ 'multipart/form-data; boundary="==' )
215215 # XXX: there ought to be tests of the uniqueness of the boundary, too.
216216
217217 def test_message_rfc822_only (self ):
@@ -303,7 +303,7 @@ def test_as_string(self):
303303 self .assertEqual (text , str (msg ))
304304 fullrepr = msg .as_string (unixfrom = True )
305305 lines = fullrepr .split ('\n ' )
306- self .assertTrue (lines [0 ]. startswith ( 'From ' ) )
306+ self .assertStartsWith (lines [0 ], 'From ' )
307307 self .assertEqual (text , NL .join (lines [1 :]))
308308
309309 def test_as_string_policy (self ):
@@ -372,7 +372,7 @@ def test_as_bytes(self):
372372 self .assertEqual (data , bytes (msg ))
373373 fullrepr = msg .as_bytes (unixfrom = True )
374374 lines = fullrepr .split (b'\n ' )
375- self .assertTrue (lines [0 ]. startswith ( b'From ' ) )
375+ self .assertStartsWith (lines [0 ], b'From ' )
376376 self .assertEqual (data , b'\n ' .join (lines [1 :]))
377377
378378 def test_as_bytes_policy (self ):
@@ -2203,7 +2203,7 @@ def test_same_boundary_inner_outer(self):
22032203 msg = self ._msgobj ('msg_15.txt' )
22042204 # XXX We can probably eventually do better
22052205 inner = msg .get_payload (0 )
2206- self .assertTrue ( hasattr ( inner , 'defects' ) )
2206+ self .assertHasAttr ( inner , 'defects' )
22072207 self .assertEqual (len (inner .defects ), 1 )
22082208 self .assertIsInstance (inner .defects [0 ],
22092209 errors .StartBoundaryNotFoundDefect )
@@ -2315,7 +2315,7 @@ def test_no_separating_blank_line(self):
23152315 # test_defect_handling
23162316 def test_lying_multipart (self ):
23172317 msg = self ._msgobj ('msg_41.txt' )
2318- self .assertTrue ( hasattr ( msg , 'defects' ) )
2318+ self .assertHasAttr ( msg , 'defects' )
23192319 self .assertEqual (len (msg .defects ), 2 )
23202320 self .assertIsInstance (msg .defects [0 ],
23212321 errors .NoBoundaryInMultipartDefect )
@@ -3659,9 +3659,7 @@ def test_make_msgid_idstring(self):
36593659 def test_make_msgid_default_domain (self ):
36603660 with patch ('socket.getfqdn' ) as mock_getfqdn :
36613661 mock_getfqdn .return_value = domain = 'pythontest.example.com'
3662- self .assertTrue (
3663- email .utils .make_msgid ().endswith (
3664- '@' + domain + '>' ))
3662+ self .assertEndsWith (email .utils .make_msgid (), '@' + domain + '>' )
36653663
36663664 def test_Generator_linend (self ):
36673665 # Issue 14645.
@@ -4128,7 +4126,7 @@ def test_CRLFLF_at_end_of_part(self):
41284126 "--BOUNDARY--\n "
41294127 )
41304128 msg = email .message_from_string (m )
4131- self .assertTrue (msg .get_payload (0 ).get_payload (). endswith ( '\r \n ' ) )
4129+ self .assertEndsWith (msg .get_payload (0 ).get_payload (), '\r \n ' )
41324130
41334131
41344132class Test8BitBytesHandling (TestEmailBase ):
0 commit comments