You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2021/12/02 23:29:09 UTC
[airflow] branch main updated: Fixed MyPy issues in tests decorators and hooks (#19996)
This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 12ad64f Fixed MyPy issues in tests decorators and hooks (#19996)
12ad64f is described below
commit 12ad64ff00a361562d925a10223dd4bd2c4e63cc
Author: Khalid Mammadov <xm...@hotmail.com>
AuthorDate: Thu Dec 2 23:28:38 2021 +0000
Fixed MyPy issues in tests decorators and hooks (#19996)
---
tests/decorators/test_python.py | 4 ++--
tests/hooks/test_subprocess.py | 8 +++-----
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/tests/decorators/test_python.py b/tests/decorators/test_python.py
index 2355568..610fa84 100644
--- a/tests/decorators/test_python.py
+++ b/tests/decorators/test_python.py
@@ -139,8 +139,8 @@ class TestAirflowTaskDecorator(TestPythonBase):
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)
diff --git a/tests/hooks/test_subprocess.py b/tests/hooks/test_subprocess.py
index 4693da7..642b219 100644
--- a/tests/hooks/test_subprocess.py
+++ b/tests/hooks/test_subprocess.py
@@ -21,6 +21,7 @@ from pathlib import Path
from subprocess import PIPE, STDOUT
from tempfile import TemporaryDirectory
from unittest import mock
+from unittest.mock import MagicMock
from parameterized import parameterized
@@ -77,14 +78,11 @@ class TestSubprocessHook(unittest.TestCase):
@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()