diff --git a/CHANGELOG.md b/CHANGELOG.md index 032daad..20e2231 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Version 0.12.6 + +- refactor: drop logging fixture and use standard pytest logger in tests + ## Version 0.12.5 - refactor: add cleanup to `FinishEvent` handler to clean workers, listeners, subscriptions, diff --git a/pyproject.toml b/pyproject.toml index f01df7e..c05862b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "python-redux" -version = "0.12.5" +version = "0.12.6" description = "Redux implementation for Python" authors = ["Sassan Haradji "] license = "Apache-2.0" diff --git a/redux/test.py b/redux/test.py index e4cbb27..2d110cd 100644 --- a/redux/test.py +++ b/redux/test.py @@ -11,7 +11,6 @@ import pytest if TYPE_CHECKING: - from logging import Logger from pathlib import Path from _pytest.fixtures import SubRequest @@ -32,7 +31,6 @@ def __init__( *, test_id: str, path: Path, - logger: Logger, override: bool, ) -> None: """Create a new store snapshot context.""" @@ -47,7 +45,6 @@ def __init__( ): file.unlink() self.results_dir.mkdir(parents=True, exist_ok=True) - self.logger = logger def set_store(self: StoreSnapshotContext, store: Store) -> None: """Set the store to take snapshots of.""" @@ -94,7 +91,7 @@ def take(self: StoreSnapshotContext, *, title: str | None = None) -> None: mismatch_path.write_text( # pragma: no cover f'// MISMATCH: {filename}\n{new_snapshot}\n', ) - assert old_snapshot == new_snapshot, f'Store snapshot mismatch: {title}' + assert new_snapshot == old_snapshot, f'Store snapshot mismatch: {title}' self.test_counter[title] += 1 @@ -109,10 +106,7 @@ def close(self: StoreSnapshotContext) -> None: @pytest.fixture() -def store_snapshot( - request: SubRequest, - logger: Logger, -) -> Generator[StoreSnapshotContext, None, None]: +def store_snapshot(request: SubRequest) -> Generator[StoreSnapshotContext, None, None]: """Take a snapshot of the current state of the store.""" override = ( request.config.getoption( @@ -127,7 +121,6 @@ def store_snapshot( context = StoreSnapshotContext( test_id=request.node.nodeid, path=request.node.path, - logger=logger, override=override, ) yield context diff --git a/tests/conftest.py b/tests/conftest.py index e35c65c..201c37d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -6,7 +6,6 @@ import random import time import uuid -from typing import TYPE_CHECKING import pytest @@ -14,19 +13,9 @@ from redux.test import pytest_addoption, store_snapshot # noqa: E402 -if TYPE_CHECKING: - from logging import Logger - __all__ = ('store_snapshot', 'pytest_addoption') -@pytest.fixture() -def logger() -> Logger: - import logging - - return logging.getLogger('test') - - @pytest.fixture(autouse=True) def _(monkeypatch: pytest.MonkeyPatch) -> None: """Mock external resources.""" diff --git a/tests/test_todo.py b/tests/test_todo.py index 516b470..d9a2d7f 100644 --- a/tests/test_todo.py +++ b/tests/test_todo.py @@ -1,6 +1,7 @@ # ruff: noqa: D100, D101, D102, D103, D104, D107 from __future__ import annotations +import logging import time import uuid from dataclasses import replace @@ -9,12 +10,10 @@ from immutable import Immutable if TYPE_CHECKING: - from logging import Logger - from redux.test import StoreSnapshotContext -def test_todo(store_snapshot: StoreSnapshotContext, logger: Logger) -> None: +def test_todo(store_snapshot: StoreSnapshotContext) -> None: from redux import BaseAction, Store from redux.basic_types import ( BaseEvent, @@ -90,7 +89,7 @@ def reducer( store_snapshot.set_store(store) # subscription: - dummy_render = logger.info + dummy_render = logging.getLogger().info store.subscribe(dummy_render) # autorun: @@ -104,7 +103,7 @@ def reaction(_: str | None) -> None: # event listener, note that this will run async in a separate thread, so it can # include async operations like API calls, etc: - dummy_api_call = logger.info + dummy_api_call = logging.getLogger().info store.subscribe_event(CallApi, lambda event: dummy_api_call(event.parameters)) # dispatch: