Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /Extralit_extralit /extralit-server /tests /unit /test_logging.py
| import logging | |
| import pytest | |
| from extralit_server.logging import ExtralitHandler, LoggingMixin | |
| class LoggingForTest(LoggingMixin): | |
| """class for tests""" | |
| def __init__(self, a: int = 5): | |
| self.a = a | |
| def f(self): | |
| self.logger.warning("This is an warning %d", self.a) | |
| class LoggingForTestChild(LoggingForTest): | |
| """class child""" | |
| def test_logging_mixin_without_breaking_constructors(): | |
| test = LoggingForTest() | |
| test.f() | |
| assert test.logger.name == f"{__name__}.{LoggingForTest.__name__}" | |
| child = LoggingForTestChild(a=10) | |
| child.f() | |
| assert child.logger.name == f"{__name__}.{LoggingForTestChild.__name__}" | |
| assert test.logger != child.logger | |
| another_child = LoggingForTestChild(a=15) | |
| # Check logger without call property method | |
| assert another_child.__getattribute__("__logger__") == child.logger | |
| def test_logging_handler(mocker): | |
| mocker.patch.object(ExtralitHandler, "emit", autospec=True) | |
| handler = ExtralitHandler() | |
| logger = logging.getLogger(__name__) | |
| logger.handlers = [handler] | |
| logger.setLevel(logging.INFO) # Force trace | |
| logger.info("This is a test") | |
| handler.emit.assert_called() | |
| def test_configure_logging_call(): | |
| # Ensure that the root logger uses the ExtralitHandler (RichHandler if rich is installed), | |
| # whereas the other loggers do not have handlers | |
| assert isinstance(logging.getLogger().handlers[0], ExtralitHandler) | |
| assert len(logging.getLogger("extralit").handlers) == 0 | |
Xet Storage Details
- Size:
- 1.56 kB
- Xet hash:
- c439e2be41bbc75f05457921452850f46c9b0720f5a124285e664ef04b6aa753
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.