@@ -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 ):
@@ -2228,7 +2228,7 @@ def test_same_boundary_inner_outer(self):
22282228 msg = self ._msgobj ('msg_15.txt' )
22292229 # XXX We can probably eventually do better
22302230 inner = msg .get_payload (0 )
2231- self .assertTrue ( hasattr ( inner , 'defects' ) )
2231+ self .assertHasAttr ( inner , 'defects' )
22322232 self .assertEqual (len (inner .defects ), 1 )
22332233 self .assertIsInstance (inner .defects [0 ],
22342234 errors .StartBoundaryNotFoundDefect )
@@ -2340,7 +2340,7 @@ def test_no_separating_blank_line(self):
23402340 # test_defect_handling
23412341 def test_lying_multipart (self ):
23422342 msg = self ._msgobj ('msg_41.txt' )
2343- self .assertTrue ( hasattr ( msg , 'defects' ) )
2343+ self .assertHasAttr ( msg , 'defects' )
23442344 self .assertEqual (len (msg .defects ), 2 )
23452345 self .assertIsInstance (msg .defects [0 ],
23462346 errors .NoBoundaryInMultipartDefect )
@@ -3684,9 +3684,7 @@ def test_make_msgid_idstring(self):
36843684 def test_make_msgid_default_domain (self ):
36853685 with patch ('socket.getfqdn' ) as mock_getfqdn :
36863686 mock_getfqdn .return_value = domain = 'pythontest.example.com'
3687- self .assertTrue (
3688- email .utils .make_msgid ().endswith (
3689- '@' + domain + '>' ))
3687+ self .assertEndsWith (email .utils .make_msgid (), '@' + domain + '>' )
36903688
36913689 def test_Generator_linend (self ):
36923690 # Issue 14645.
@@ -4153,7 +4151,7 @@ def test_CRLFLF_at_end_of_part(self):
41534151 "--BOUNDARY--\n "
41544152 )
41554153 msg = email .message_from_string (m )
4156- self .assertTrue (msg .get_payload (0 ).get_payload (). endswith ( '\r \n ' ) )
4154+ self .assertEndsWith (msg .get_payload (0 ).get_payload (), '\r \n ' )
41574155
41584156
41594157class Test8BitBytesHandling (TestEmailBase ):
0 commit comments