windmark commented on code in PR #27502:
URL: https://github.com/apache/airflow/pull/27502#discussion_r1015321554
##########
kubernetes_tests/test_kubernetes_pod_operator.py:
##########
@@ -934,21 +951,19 @@ def test_pod_template_file(
pod_mock.status.phase = "Succeeded"
await_pod_completion_mock.return_value = pod_mock
context = create_context(k)
- with self.assertLogs(k.log, level=logging.DEBUG) as cm:
+ with caplog.at_level(logging.DEBUG, logger="airflow.task"):
k.execute(context)
- expected_line = textwrap.dedent(
- """\
- DEBUG:airflow.task.operators:Starting pod:
- api_version: v1
- kind: Pod
- metadata:
- annotations: {}
- cluster_name: null
- creation_timestamp: null
- deletion_grace_period_seconds: null\
- """
- ).strip()
- assert any(line.startswith(expected_line) for line in cm.output)
+ expected_line = (
Review Comment:
Due to the different log format of `caplog`, I decided to reformat this to a
regex search instead of the `any(...` logic. This was easier to do with this
string format instead of the multiline.
##########
kubernetes_tests/test_kubernetes_pod_operator.py:
##########
@@ -810,7 +816,11 @@ def test_pod_template_file_with_full_pod_spec(self):
assert k.pod.spec.containers[0].env == [k8s.V1EnvVar(name="env_name",
value="value")]
assert result == {"hello": "world"}
- def test_full_pod_spec(self):
+ @pytest.mark.parametrize(
Review Comment:
Adding support for this required me to move from a `unittest.TestCase` to
pytest. This required a couple of other fixes, but is worth it in my mind,
since other test classes are using pytest.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]