Skip to content

Commit

Permalink
Fix linter for test
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jopel committed Oct 7, 2024
1 parent a6c8ed1 commit f055bfb
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions opentelemetry-sdk/tests/logs/test_logger_provider_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,40 +27,43 @@ class TestLoggerProviderCache(unittest.TestCase):

def test_get_logger_single_handler(self):
handler, logger_provider = set_up_logging_handler(level=logging.DEBUG)

# pylint: disable=protected-access
logger_cache = logger_provider._logger_cache
logger = create_logger(handler, "test_logger")

# Ensure logger is lazily cached
self.assertEqual(0, len(logger_provider._logger_cache))
self.assertEqual(0, len(logger_cache))

logger.warning("test message")

self.assertEqual(1, len(logger_provider._logger_cache))
self.assertEqual(1, len(logger_cache))

# Ensure only one logger is cached
rounds = 100
for _ in range(rounds):
logger.warning("test message")

self.assertEqual(1, len(logger_provider._logger_cache))
self.assertEqual(1, len(logger_cache))

def test_get_logger_multiple_loggers(self):
handler, logger_provider = set_up_logging_handler(level=logging.DEBUG)
# pylint: disable=protected-access
logger_cache = logger_provider._logger_cache

num_loggers = 10
loggers = [create_logger(handler, str(i)) for i in range(num_loggers)]

# Ensure loggers are lazily cached
self.assertEqual(0, len(logger_provider._logger_cache))
self.assertEqual(0, len(logger_cache))

for logger in loggers:
logger.warning("test message")

self.assertEqual(num_loggers, len(logger_provider._logger_cache))
self.assertEqual(num_loggers, len(logger_cache))

rounds = 100
for _ in range(rounds):
for logger in loggers:
logger.warning("test message")

self.assertEqual(num_loggers, len(logger_provider._logger_cache))
self.assertEqual(num_loggers, len(logger_cache))

0 comments on commit f055bfb

Please sign in to comment.