Skip to content

Commit

Permalink
Fixed unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Nusnus committed Dec 25, 2023
1 parent 7a7a2d5 commit 6e244df
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
16 changes: 8 additions & 8 deletions src/pytest_celery/vendors/worker/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Check warning on line 66 in src/pytest_celery/vendors/worker/volume.py

View check run for this annotation

Codecov / codecov/patch

src/pytest_celery/vendors/worker/volume.py#L66

Added line #L66 was not covered by tests
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,
]
)

Expand Down
10 changes: 6 additions & 4 deletions tests/unit/vendors/test_worker/test_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 6e244df

Please sign in to comment.