Repository navigation
Add missing tests for cncf.kubernetes script and delete utilities #72265
Description
Description
Two modules in the cncf.kubernetes provider have no dedicated test module, and (unlike most entries on the OVERLOOKED_TESTS list) they are not covered indirectly. Nothing under any providers/*/tests/ directory imports them at all:
| Module | Expected test file |
|---|---|
providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/python_kubernetes_script.py |
providers/cncf/kubernetes/tests/unit/cncf/kubernetes/test_python_kubernetes_script.py |
providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/utils/delete_from.py |
providers/cncf/kubernetes/tests/unit/cncf/kubernetes/utils/test_delete_from.py |
Both are currently suppressed in the OVERLOOKED_TESTS allowlist in airflow-core/tests/unit/always/test_project_structure.py.
This is a scoped subset of the meta issue #35442, limited to the cncf.kubernetes provider.
What should these tests cover?
python_kubernetes_script.py backs the @task.kubernetes decorator. remove_task_decorator does string surgery on user source, stripping @setup, @teardown and the task decorator itself, with _balance_parens walking nested parentheses to find where a parameterised decorator ends. That is easy to break and the failure mode is silently corrupted user code, so it is worth covering directly:
- a decorator with no arguments, with arguments, and with nested parentheses inside the arguments
- source carrying
@setupand@teardownalongside the task decorator - source where the decorator name never appears, which should return the input unchanged
write_python_scriptrendering the Jinja template to the target file, includingrender_template_as_native_obj=TrueselectingNativeEnvironment, andStrictUndefinedraising on a missing context variable
While writing these it is worth pinning the current behaviour of the inner _remove_task_decorator, which reads python_source from the enclosing scope rather than its own py_source argument. The two happen to be the same object on every iteration of the loop that calls it, so the result is correct today, but nothing stops that from silently changing.
delete_from.py is vendored from kubernetes_asyncio and mirrors the upstream create_from_yaml helpers. Worth covering:
- the API class name derivation in
_delete_from_yaml_single_itemfromapiVersion, covering the core group, a named group,.k8s.iostripping, and DNS subdomain to CamelCase conversion - the kind conversion from CamelCase to snake_case
- namespaced versus non namespaced dispatch, meaning
delete_namespaced_<kind>when the API exposes it anddelete_<kind>otherwise - a
namespacein the document metadata taking precedence over thenamespaceargument, which the code calls out explicitly Listkinds fanning out overitemsand inheritingapiVersionfrom the parent documentApiExceptions being collected rather than raised eagerly, then surfaced together asFailToDeleteError, plus theFailToDeleteError.__str__formatting
These can all be driven with mocked kubernetes.client API classes using autospec, so no cluster is required.
Definition of Done
- Add the two test modules at the paths in the table above.
- Remove the two corresponding entries from
OVERLOOKED_TESTSinairflow-core/tests/unit/always/test_project_structure.py - Both of these tests should pass:
breeze testing providers-tests providers/cncf/kubernetes/tests/unit/cncf/kubernetes/test_python_kubernetes_script.py
breeze testing providers-tests providers/cncf/kubernetes/tests/unit/cncf/kubernetes/utils/test_delete_from.pyDrafted-by: Claude Code (Opus 5); reviewed and edited by @jroachgolf84 before posting.
Activity
jroachgolf84 commentedon Aug 29, 2026
This is an issue that is reserved for the Airflow Summit "Contributors" Workshop. This is denoted with the labelcontributors-workshop. Out of respect for the organizers and participants of this workshop, please do not implement a PR that addresses this issue.If this issue is still open following Airflow Summit, the label will be removed and the issue can be picked up.jroachgolf84 commentedon Sep 2, 2026
This issue is now open for contribution. Please feel free to create a PR!
mohit716 commentedon Sep 16, 2026
I'd love to take a stab at this issue and work on the missing test coverage!
Sanskar121543 commentedon Oct 14, 2026
I'd like to work on this - will add the two missing test modules (test_python_kubernetes_script.py and test_delete_from.py) per the spec above.
Sanskar121543 commentedon Oct 14, 2026
Correction: I missed that this already has open PRs (#74424, #74524, #72461) addressing it - apologies for the noise, stepping back from this one.
Add unit tests for amazon aws lambda executor utils (apache#72265)
Add unit tests for amazon aws lambda executor utils and docker app (a…
Add unit tests for auth manager login datamodels (#72265) (#75544)