7171@pytest .fixture
7272def clean_logger ():
7373 """Provide a clean logger with no handlers or filters."""
74- logger = logging .getLogger ("test_logger_" + str ( time . time ()) )
74+ logger = logging .getLogger ("test_logger_handlers" )
7575 logger .handlers = []
7676 logger .filters = []
7777 logger .setLevel (logging .DEBUG )
@@ -100,7 +100,7 @@ def ers_log_record():
100100 name = "test.module" ,
101101 level = logging .ERROR ,
102102 pathname = "/path/to/test.py" ,
103- lineno = 42 ,
103+ lineno = 67 ,
104104 msg = "ERS message" ,
105105 args = (),
106106 exc_info = None ,
@@ -116,7 +116,7 @@ def mock_ers_handlers():
116116 for level_var in level_to_ers_var .values ():
117117 conf = ERSPyLogHandlerConf (
118118 handlers = [HandlerType .Throttle , HandlerType .Protobufstream ],
119- protobufconf = ProtobufConf (url = "test.kafka.com " , port = 9092 ),
119+ protobufconf = ProtobufConf (url = "monkafka.cern.ch " , port = 30092 ),
120120 )
121121 handlers_config [level_var ] = conf
122122 return handlers_config
@@ -160,38 +160,14 @@ def test_ers_path_valid_configuration(self, ers_log_record, mock_ers_handlers):
160160
161161 assert allowed == [HandlerType .Throttle , HandlerType .Protobufstream ]
162162
163- def test_ers_path_missing_ers_handlers_attribute (self , ers_log_record ):
164- """Test get_allowed() returns None when ERS record lacks ers_handlers."""
165- # ers_log_record has stream=ERS but no ers_handlers attribute
166- filter_obj = BaseHandlerFilter ()
167-
168- allowed = filter_obj .get_allowed (ers_log_record )
169-
170- assert allowed is None
171-
172163 def test_ers_path_no_matching_level_variable (self , ers_log_record , mock_ers_handlers ):
173164 """Test get_allowed() returns None when log level has no ERS mapping."""
174- # Set a log level that might not have an ERS equivalent
165+ # Set a log level that does not have an ERS equivalent
175166 ers_log_record .levelno = 25 # Between INFO and WARNING
176167 ers_log_record .ers_handlers = mock_ers_handlers
177168 filter_obj = BaseHandlerFilter ()
178169
179170 allowed = filter_obj .get_allowed (ers_log_record )
180-
181- # Level 25 likely won't map to any ERS variable, so should return None
182- # or might map to something - let's handle both cases
183- if 25 not in level_to_ers_var :
184- assert allowed is None
185-
186- def test_ers_path_missing_handler_conf_for_level (self , ers_log_record ):
187- """Test get_allowed() returns None when handler conf missing for level."""
188- ers_log_record .levelno = logging .DEBUG # Low level
189- # Provide partial ers_handlers config missing the DEBUG entry
190- ers_log_record .ers_handlers = {}
191- filter_obj = BaseHandlerFilter ()
192-
193- allowed = filter_obj .get_allowed (ers_log_record )
194-
195171 assert allowed is None
196172
197173
@@ -382,20 +358,6 @@ def test_timestamp_formatting(self):
382358 assert formatted .count ("-" ) == 2 # Two dashes for date
383359 assert formatted .count (":" ) == 2 # Two colons for time
384360
385- def test_report_suppression_not_called_when_counter_zero (self , log_record ):
386- """Test that _report_suppression returns early if suppressed_counter is 0."""
387- filter_obj = ThrottleFilter ()
388- issue_record = IssueRecord ()
389- issue_record .suppressed_counter = 0
390-
391- with patch .object (filter_obj , "_report_suppression" ) as mock_report :
392- filter_obj ._report_suppression (issue_record , log_record )
393-
394- # Should return early without doing anything
395- # (We can't easily test this without mocking, but the logic is clear)
396- # Just verify the method completes without error
397- assert True
398-
399361 def test_different_issues_tracked_separately (self , log_record ):
400362 """Test that different file:line combinations track state separately."""
401363 filter_obj = ThrottleFilter (initial_threshold = 2 , time_limit = 10 )
0 commit comments