@@ -404,6 +404,20 @@ def test_empty_filter(self):
404404 r = logging .makeLogRecord ({'name' : 'spam.eggs' })
405405 self .assertTrue (f .filter (r ))
406406
407+ def test_filter_repr (self ):
408+ f = logging .Filter ('myapp' )
409+ self .assertEqual (repr (f ), '<Filter (myapp)>' )
410+
411+ def test_filter_repr_empty (self ):
412+ f = logging .Filter ()
413+ self .assertEqual (repr (f ), '<Filter ()>' )
414+
415+ def test_filter_repr_subclass (self ):
416+ class MyFilter (logging .Filter ):
417+ pass
418+ f = MyFilter ('myapp' )
419+ self .assertEqual (repr (f ), '<MyFilter (myapp)>' )
420+
407421#
408422# First, we define our levels. There can be as many as you want - the only
409423# limitations are that they should be integers, the lowest should be > 0 and
@@ -4914,6 +4928,20 @@ def test_relativeCreated_has_higher_precision(self):
49144928 # After PR gh-102412, precision (places) increases from 3 to 7
49154929 self .assertAlmostEqual (relativeCreated , offset_ns / 1e6 , places = 7 )
49164930
4931+ def test_formatter_repr (self ):
4932+ f = logging .Formatter ('%(message)s' )
4933+ self .assertEqual (repr (f ), '<Formatter (%(message)s)>' )
4934+
4935+ def test_formatter_repr_default (self ):
4936+ f = logging .Formatter ()
4937+ self .assertEqual (repr (f ), '<Formatter (%(message)s)>' )
4938+
4939+ def test_formatter_repr_subclass (self ):
4940+ class MyFormatter (logging .Formatter ):
4941+ pass
4942+ f = MyFormatter ('%(message)s' )
4943+ self .assertEqual (repr (f ), '<MyFormatter (%(message)s)>' )
4944+
49174945
49184946class TestBufferingFormatter (logging .BufferingFormatter ):
49194947 def formatHeader (self , records ):
0 commit comments