dstandish commented on code in PR #26973:
URL: https://github.com/apache/airflow/pull/26973#discussion_r991528758


##########
tests/providers/google/cloud/utils/test_credentials_provider.py:
##########
@@ -349,7 +367,7 @@ def test_disable_logging(self, mock_default, mock_info, 
mock_file):
                 key_path='KEY.json',
                 disable_logging=True,
             )
-        assert logs.output == ['DEBUG:root:nothing']
+        assert_no_logs(logs.records)

Review Comment:
   Hey @Taragolis , building off your work, i got inspired, and figured out we 
could wrap this logic in a context mgr and make it all even cleaner.
   
   No obligation to accept it but here is the code
   
   ```suggestion
           assert_no_logs(logs.records)
   
       @contextmanager
       def assert_no_logs(self, name, level):
           with self.assertLogs(level=level) as logs:
               logging.debug('nothing')
               yield
           records = [log_record for log_record in logs.records if 
log_record.name == name]
           if not records:
               return
           raise AssertionError(f"Did not expect any log message from 
logger={name!r}, but got: {records}")
   
   
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to