Unverified Commit d336c56d authored by Yih-Dar's avatar Yih-Dar Committed by GitHub
Browse files

Avoid root logger's level being changed (#28638)



* avoid root logger's level being changed

---------
Co-authored-by: default avatarydshieh <ydshieh@users.noreply.github.com>
parent bf674153
...@@ -50,6 +50,7 @@ from transformers.testing_utils import ( ...@@ -50,6 +50,7 @@ from transformers.testing_utils import (
TOKEN, TOKEN,
USER, USER,
CaptureLogger, CaptureLogger,
LoggingLevel,
TestCasePlus, TestCasePlus,
backend_device_count, backend_device_count,
execute_subprocess_async, execute_subprocess_async,
...@@ -1290,12 +1291,14 @@ class TrainerIntegrationTest(TestCasePlus, TrainerIntegrationCommon): ...@@ -1290,12 +1291,14 @@ class TrainerIntegrationTest(TestCasePlus, TrainerIntegrationCommon):
else: else:
self.assertNotIn(log_info_string, cl.out) self.assertNotIn(log_info_string, cl.out)
with LoggingLevel(logging.INFO):
# test with low log_level - lower than info # test with low log_level - lower than info
with CaptureLogger(logger) as cl: with CaptureLogger(logger) as cl:
trainer = get_regression_trainer(log_level="debug") trainer = get_regression_trainer(log_level="debug")
trainer.train() trainer.train()
self.assertIn(log_info_string, cl.out) self.assertIn(log_info_string, cl.out)
with LoggingLevel(logging.INFO):
# test with high log_level - should be quiet # test with high log_level - should be quiet
with CaptureLogger(logger) as cl: with CaptureLogger(logger) as cl:
trainer = get_regression_trainer(log_level="error") trainer = get_regression_trainer(log_level="error")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment