this works when i run the test individually
however when running all my test, these 4 always fail
I have tried
- no logger
- caplog.set_level(..., logger="test_registry")
none worked when running all tests, but worked when tested individually
@pytest.fixture
def registry(caplog):
# Create a new logger for the test
logger = logging.getLogger("test_registry")
logger.setLevel(logging.DEBUG)
# Make sure the logger propagates to the root logger where caplog is listening
logger.propagate = True
# Create registry with the logger
registry = Registry(logger=logger)
yield registry
registry.reset()
def test_registry_logging_register(registry, caplog):
caplog.set_level(logging.DEBUG)
registry.register('argInt', 1)
assert f"{registry.registry_name}: Registered `argInt` to registry" in caplog.text
with pytest.raises(DuplicateKeyError):
registry.register('argInt', 2)
assert f"{registry.registry_name}: `argInt` already registered." in caplog.text
Error
tests\test_registryManager\test_registryManager_logging.py:63 (test_registry_logging_get)
'BaseRegistry: `notExistingKey` not registered.' != ''
Expected :''
Actual :'BaseRegistry: `notExistingKey` not registered.'
<Click to see difference>
registry = <Registry name='BaseRegistry', items=0>
caplog = <_pytest.logging.LogCaptureFixture object at 0x00000240F2B299A0>
def test_registry_logging_get(registry, caplog):
caplog.set_level(logging.DEBUG)
with pytest.raises(MissingKeyError):
registry.get('notExistingKey')
> assert f"{registry.registry_name}: `notExistingKey` not registered." in caplog.text
E AssertionError: assert 'BaseRegistry: `notExistingKey` not registered.' in ''
E + where '' = <_pytest.logging.LogCaptureFixture object at 0x00000240F2B299A0>.text