You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jobs@airflow.apache.org by GitBox <gi...@apache.org> on 2025/09/20 02:37:38 UTC
[GH] (airflow/fix-celery-test): Workflow run "Tests AMD" failed!
The GitHub Actions job "Tests AMD" on airflow.git/fix-celery-test has failed.
Run started by GitHub user kaxil (triggered by kaxil).
Head commit for run:
9a3e4be0fa6b56bb7e38972c04ec10373049869b / Kaxil Naik <ka...@gmail.com>
Fix pytest collection failure for classes decorated with context managers
Classes decorated with `@conf_vars` and other context managers were disappearing
during pytest collection, causing tests to be silently skipped. This affected
several test classes including `TestWorkerStart` in the Celery provider tests.
Root cause: `ContextDecorator` transforms decorated classes into callable wrappers.
Since pytest only collects actual type objects as test classes, these wrapped
classes are ignored during collection.
Simple reproduction (no Airflow needed):
```py
import contextlib
import inspect
@contextlib.contextmanager
def simple_cm():
yield
@simple_cm()
class TestExample:
def test_method(self):
pass
print(f'Is class? {inspect.isclass(TestExample)}') # False - pytest won't collect
```
and then run
```shell
pytest test_example.py --collect-only
```
Airflow reproduction:
```shell
breeze run pytest providers/celery/tests/unit/celery/cli/test_celery_command.py --collect-only -v
breeze run pytest providers/celery/tests/unit/celery/cli/test_celery_command.py --collect-only -v
```
Solution:
1. Fixed affected test files by replacing class-level `@conf_vars` decorators
with pytest fixtures
2. Created pytest fixtures to apply configuration changes
3. Used `@pytest.mark.usefixtures` to apply configuration to test classes
4. Added custom linter to prevent future occurrences and integrated it
into pre-commit hooks
Files changed:
- Fixed 3 test files with problematic class decorators
- Added custom linter with pre-commit integration
This ensures pytest properly collects all test classes and prevents similar
issues in the future through automated detection.
Report URL: https://github.com/apache/airflow/actions/runs/17873753882
With regards,
GitHub Actions via GitBox
---------------------------------------------------------------------
To unsubscribe, e-mail: jobs-unsubscribe@airflow.apache.org
For additional commands, e-mail: jobs-help@airflow.apache.org