@@ -1134,7 +1134,7 @@ def test_basic(self):
11341134 self .assertEqual (mailfrom , 'me' )
11351135 self .assertEqual (rcpttos , ['you' ])
11361136 self .assertIn ('\n Subject: Log\n ' , data )
1137- self .assertTrue (data . endswith ( '\n \n Hello \u2713 ' ) )
1137+ self .assertEndsWith (data , '\n \n Hello \u2713 ' )
11381138 h .close ()
11391139
11401140 def process_message (self , * args ):
@@ -3524,7 +3524,7 @@ def test_config14_ok(self):
35243524 self .assertEqual (h .foo , 'bar' )
35253525 self .assertEqual (h .terminator , '!\n ' )
35263526 logging .warning ('Exclamation' )
3527- self .assertTrue (output .getvalue (). endswith ( 'Exclamation!\n ' ) )
3527+ self .assertEndsWith (output .getvalue (), 'Exclamation!\n ' )
35283528
35293529 def test_config15_ok (self ):
35303530
@@ -4281,7 +4281,7 @@ def test_queue_handler(self):
42814281 msg = self .next_message ()
42824282 self .que_logger .warning (msg )
42834283 data = self .queue .get_nowait ()
4284- self .assertTrue ( isinstance ( data , logging .LogRecord ) )
4284+ self .assertIsInstance ( data , logging .LogRecord )
42854285 self .assertEqual (data .name , self .que_logger .name )
42864286 self .assertEqual ((data .msg , data .args ), (msg , None ))
42874287
@@ -4879,14 +4879,14 @@ def test_formatting(self):
48794879 r .removeHandler (h )
48804880 h .close ()
48814881 r = h .records [0 ]
4882- self .assertTrue (r .exc_text . startswith ( 'Traceback (most recent '
4883- ' call last):\n ') )
4884- self .assertTrue (r .exc_text . endswith ( ' \n RuntimeError: '
4885- ' deliberate mistake') )
4886- self .assertTrue (r .stack_info . startswith ( 'Stack (most recent '
4887- ' call last):\n ') )
4888- self .assertTrue (r .stack_info . endswith ( 'logging.exception( \' failed \' , '
4889- ' stack_info=True)' ) )
4882+ self .assertStartsWith (r .exc_text ,
4883+ 'Traceback (most recent call last):\n ' )
4884+ self .assertEndsWith (r .exc_text ,
4885+ ' \n RuntimeError: deliberate mistake' )
4886+ self .assertStartsWith (r .stack_info ,
4887+ 'Stack (most recent call last):\n ' )
4888+ self .assertEndsWith (r .stack_info ,
4889+ "logging.exception('failed', stack_info=True)" )
48904890
48914891
48924892class LastResortTest (BaseTest ):
@@ -5229,8 +5229,8 @@ class LogRecordTest(BaseTest):
52295229 def test_str_rep (self ):
52305230 r = logging .makeLogRecord ({})
52315231 s = str (r )
5232- self .assertTrue ( s . startswith ( '<LogRecord: ' ) )
5233- self .assertTrue ( s . endswith ( '>' ) )
5232+ self .assertStartsWith ( s , '<LogRecord: ' )
5233+ self .assertEndsWith ( s , '>' )
52345234
52355235 def test_dict_arg (self ):
52365236 h = RecordingHandler ()
@@ -5880,14 +5880,14 @@ def test_extra_in_records(self):
58805880 self .adapter .critical ('foo should be here' )
58815881 self .assertEqual (len (self .recording .records ), 1 )
58825882 record = self .recording .records [0 ]
5883- self .assertTrue ( hasattr ( record , 'foo' ) )
5883+ self .assertHasAttr ( record , 'foo' )
58845884 self .assertEqual (record .foo , '1' )
58855885
58865886 def test_extra_not_merged_by_default (self ):
58875887 self .adapter .critical ('foo should NOT be here' , extra = {'foo' : 'nope' })
58885888 self .assertEqual (len (self .recording .records ), 1 )
58895889 record = self .recording .records [0 ]
5890- self .assertFalse ( hasattr ( record , 'foo' ) )
5890+ self .assertNotHasAttr ( record , 'foo' )
58915891
58925892 def test_extra_merged (self ):
58935893 self .adapter = logging .LoggerAdapter (logger = self .logger ,
@@ -5897,8 +5897,8 @@ def test_extra_merged(self):
58975897 self .adapter .critical ('foo and bar should be here' , extra = {'bar' : '2' })
58985898 self .assertEqual (len (self .recording .records ), 1 )
58995899 record = self .recording .records [0 ]
5900- self .assertTrue ( hasattr ( record , 'foo' ) )
5901- self .assertTrue ( hasattr ( record , 'bar' ) )
5900+ self .assertHasAttr ( record , 'foo' )
5901+ self .assertHasAttr ( record , 'bar' )
59025902 self .assertEqual (record .foo , '1' )
59035903 self .assertEqual (record .bar , '2' )
59045904
@@ -5910,7 +5910,7 @@ def test_extra_merged_log_call_has_precedence(self):
59105910 self .adapter .critical ('foo shall be min' , extra = {'foo' : '2' })
59115911 self .assertEqual (len (self .recording .records ), 1 )
59125912 record = self .recording .records [0 ]
5913- self .assertTrue ( hasattr ( record , 'foo' ) )
5913+ self .assertHasAttr ( record , 'foo' )
59145914 self .assertEqual (record .foo , '2' )
59155915
59165916
@@ -6624,18 +6624,19 @@ def namer(filename):
66246624 p = '%s.log.' % prefix
66256625 for c in candidates :
66266626 d , fn = os .path .split (c )
6627- self .assertTrue (fn . startswith ( p ) )
6627+ self .assertStartsWith (fn , p )
66286628 elif prefix .startswith ('d.e' ):
66296629 for c in candidates :
66306630 d , fn = os .path .split (c )
6631- self .assertTrue (fn . endswith ( '.log' ), fn )
6632- self .assertTrue (fn . startswith ( prefix + '.' ) and
6633- fn [len (prefix ) + 2 ].isdigit ())
6631+ self .assertEndsWith (fn , '.log' )
6632+ self .assertStartsWith (fn , prefix + '.' )
6633+ self . assertTrue ( fn [len (prefix ) + 2 ].isdigit ())
66346634 elif prefix == 'g' :
66356635 for c in candidates :
66366636 d , fn = os .path .split (c )
6637- self .assertTrue (fn .endswith ('.oldlog' ))
6638- self .assertTrue (fn .startswith ('g' ) and fn [1 ].isdigit ())
6637+ self .assertEndsWith (fn , '.oldlog' )
6638+ self .assertStartsWith (fn , 'g' )
6639+ self .assertTrue (fn [1 ].isdigit ())
66396640
66406641 def test_compute_files_to_delete_same_filename_different_extensions (self ):
66416642 # See GH-93205 for background
@@ -6673,7 +6674,7 @@ def test_compute_files_to_delete_same_filename_different_extensions(self):
66736674 matcher = re .compile (r"^\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}\Z" )
66746675 for c in candidates :
66756676 d , fn = os .path .split (c )
6676- self .assertTrue (fn . startswith ( prefix + '.' ) )
6677+ self .assertStartsWith (fn , prefix + '.' )
66776678 suffix = fn [(len (prefix )+ 1 ):]
66786679 self .assertRegex (suffix , matcher )
66796680
0 commit comments