Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed MyPy issues in tests decorators and hooks #19996

Merged
merged 1 commit into from Dec 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/decorators/test_python.py
Expand Up @@ -139,8 +139,8 @@ def identity_notyping(x: int):

def test_manual_multiple_outputs_false_with_typings(self):
@task_decorator(multiple_outputs=False)
def identity2(x: int, y: int) -> Dict[int, int]:
return (x, y)
def identity2(x: int, y: int) -> Tuple[int, int]:
return x, y

with self.dag:
res = identity2(8, 4)
Expand Down
8 changes: 3 additions & 5 deletions tests/hooks/test_subprocess.py
Expand Up @@ -21,6 +21,7 @@
from subprocess import PIPE, STDOUT
from tempfile import TemporaryDirectory
from unittest import mock
from unittest.mock import MagicMock

from parameterized import parameterized

Expand Down Expand Up @@ -77,14 +78,11 @@ def test_return_value(self, val, expected):
@mock.patch.dict('os.environ', clear=True)
@mock.patch(
"airflow.hooks.subprocess.TemporaryDirectory",
**{'return_value.__enter__.return_value': '/tmp/airflowtmpcatcat'}, # type: ignore
return_value=MagicMock(__enter__=MagicMock(return_value='/tmp/airflowtmpcatcat')),
)
@mock.patch(
"airflow.hooks.subprocess.Popen",
**{ # type: ignore
'return_value.stdout.readline.side_effect': [b'BAR', b'BAZ'],
'return_value.returncode': 0,
},
return_value=MagicMock(stdout=MagicMock(readline=MagicMock(side_effect=StopIteration), returncode=0)),
)
def test_should_exec_subprocess(self, mock_popen, mock_temporary_directory):
hook = SubprocessHook()
Expand Down