Skip to content

tests: skip test_celery gracefully when celery/testcontainers aren't installed - #752

Open
dchaudhari7177 wants to merge 1 commit into
pytest-dev:masterfrom
dchaudhari7177:fix/skip-celery-test-when-not-installed
Open

tests: skip test_celery gracefully when celery/testcontainers aren't installed#752
dchaudhari7177 wants to merge 1 commit into
pytest-dev:masterfrom
dchaudhari7177:fix/skip-celery-test-when-not-installed

Conversation

@dchaudhari7177

Copy link
Copy Markdown

Fixes #750.

test_celery generates a test module that does from celery import Celery / from celery.contrib.testing import worker / from testcontainers.redis import RedisContainer. When those packages aren't installed the inner pytester.runpytest(...) errors out with ImportError, so the test fails hard instead of being skipped. The existing sys.platform skips only cover Windows/macOS, so on other platforms (e.g. FreeBSD, per the report) it blows up.

This adds a skipif guarding on celery and testcontainers being importable (via importlib.util.find_spec), matching how the suite already gates optional/platform-specific tests. When both are installed the test runs exactly as before.

Verified locally: with neither package installed, test_celery now reports SKIPPED [celery and testcontainers are required] instead of erroring; ruff check/format clean.

Happy to add a CHANGELOG.rst entry in whatever section you'd prefer for an unreleased test-only fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Celery tests require package; test blows up if Celery not installed instead of skipping the tests gracefully

1 participant