Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dstandish committed Jun 25, 2022
1 parent adef662 commit 6255d97
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
21 changes: 1 addition & 20 deletions tests/models/test_taskinstance.py
Expand Up @@ -57,7 +57,7 @@
)
from airflow.models.serialized_dag import SerializedDagModel
from airflow.models.taskfail import TaskFail
from airflow.models.taskinstance import TaskInstance, _executor_config_comparator
from airflow.models.taskinstance import TaskInstance
from airflow.models.taskmap import TaskMap
from airflow.models.xcom import XCOM_RETURN_KEY
from airflow.operators.bash import BashOperator
Expand Down Expand Up @@ -2848,22 +2848,3 @@ def get_extra_env():

echo_task = dag.get_task("echo")
assert "get_extra_env" in echo_task.upstream_task_ids


def test_executor_config_comparator():
"""
When comparison raises AttributeError, return False.
This can happen when executor config contains kubernetes objects pickled
under older kubernetes library version.
"""

class MockAttrError:
def __eq__(self, other):
raise AttributeError('hello')

a = MockAttrError()
with pytest.raises(AttributeError):
# just verify for ourselves that this throws
assert a == a
assert _executor_config_comparator(a, a) is False
assert _executor_config_comparator('a', 'a') is True
20 changes: 20 additions & 0 deletions tests/utils/test_sqlalchemy.py
Expand Up @@ -294,3 +294,23 @@ def test_result_processor(self, input):
# it was serialized with BaseSerialization (which is the behavior added in #24356
expected['pod_override'] = BaseSerialization()._deserialize(expected['pod_override'])
assert result == expected

def test_compare_values(self):
"""
When comparison raises AttributeError, return False.
This can happen when executor config contains kubernetes objects pickled
under older kubernetes library version.
"""

class MockAttrError:
def __eq__(self, other):
raise AttributeError('hello')

a = MockAttrError()
with pytest.raises(AttributeError):
# just verify for ourselves that comparing directly will throw AttributeError
assert a == a

instance = ExecutorConfigType()
assert instance.compare_values(a, a) is False
assert instance.compare_values('a', 'a') is True

0 comments on commit 6255d97

Please sign in to comment.