From 6e244df5736044d9d4934272d000d3cb91ab1d38 Mon Sep 17 00:00:00 2001 From: Tomer Nosrati Date: Tue, 26 Dec 2023 00:09:23 +0200 Subject: [PATCH] Fixed unit tests --- src/pytest_celery/vendors/worker/volume.py | 16 ++++++++-------- tests/unit/vendors/test_worker/test_volume.py | 10 ++++++---- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/pytest_celery/vendors/worker/volume.py b/src/pytest_celery/vendors/worker/volume.py index bc396ee5..847cd8b6 100644 --- a/src/pytest_celery/vendors/worker/volume.py +++ b/src/pytest_celery/vendors/worker/volume.py @@ -63,19 +63,19 @@ def __init__( self.set_app_name() self.set_config_from_object() - def __eq__(self, __value: object) -> bool: - if not isinstance(__value, WorkerInitialContent): + def __eq__(self, other: WorkerInitialContent) -> bool: + if not isinstance(other, WorkerInitialContent): return False try: - return self.generate() == __value.generate() + return self.generate() == other.generate() except ValueError: return all( [ - self._app_module_src == __value._app_module_src, - self._utils_module_src == __value._utils_module_src, - self._initial_content == __value._initial_content, - self._app == __value._app, - self._config == __value._config, + self._app_module_src == other._app_module_src, + self._utils_module_src == other._utils_module_src, + self._initial_content == other._initial_content, + self._app == other._app, + self._config == other._config, ] ) diff --git a/tests/unit/vendors/test_worker/test_volume.py b/tests/unit/vendors/test_worker/test_volume.py index 33850184..bd9fb467 100644 --- a/tests/unit/vendors/test_worker/test_volume.py +++ b/tests/unit/vendors/test_worker/test_volume.py @@ -115,12 +115,15 @@ def test_set_app_module(self): ) def test_add_modules(self, modules: dict[str, set[ModuleType]]): from pytest_celery.vendors.worker.content import app as app_module + from pytest_celery.vendors.worker.content import utils as utils_module actual_content = WorkerInitialContent() expected_content = WorkerInitialContent() actual_content.set_app_module(app_module) + actual_content.set_utils_module(utils_module) expected_content.set_app_module(app_module) + expected_content.set_utils_module(utils_module) for module_name, module_set in modules.items(): actual_content.add_modules(module_name, module_set) @@ -173,14 +176,13 @@ def test_generate_default(self): ) def test_generate(self, app: Celery | None): from pytest_celery.vendors.worker.content import app as app_module + from pytest_celery.vendors.worker.content import utils as utils_module - actual_content = WorkerInitialContent() - - actual_content.set_app_module(app_module) + actual_content = WorkerInitialContent(app_module, utils_module) actual_content.add_modules("tests_modules", {pytest, pytest_celery}) actual_content.set_config_from_object(app) - expected_content = WorkerInitialContent(app_module) + expected_content = WorkerInitialContent(app_module, utils_module) expected_content.add_modules("tests_modules", {pytest, pytest_celery}) expected_content.set_config_from_object(app)