test_jid_logging.py 828 B

123456789101112131415161718192021222324252627282930
  1. import logging
  2. from tests.support.case import ModuleCase
  3. from tests.support.helpers import TstSuiteLoggingHandler, flaky
  4. from tests.support.unit import skipIf
  5. @skipIf(True, "Runtest Log Hander Disabled for PY3, #41836")
  6. class LoggingJIDsTest(ModuleCase):
  7. """
  8. Validate that JIDs appear in LOGs
  9. """
  10. def setUp(self):
  11. """
  12. Set up
  13. """
  14. log_format = "[%(levelname)-8s] %(jid)s %(message)s"
  15. self.handler = TstSuiteLoggingHandler(format=log_format, level=logging.DEBUG)
  16. @flaky
  17. def test_jid_in_logs(self):
  18. """
  19. Test JID in log_format
  20. """
  21. with self.handler:
  22. self.run_function("test.ping")
  23. assert (
  24. any("JID" in s for s in self.handler.messages) is True
  25. ), "JID not found in log messages"