-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
unittest.mock.patch decorator doesn't accept args #3270
Comments
I am not sure what is going on, but I can't reproduce it with this simple test case: from unittest import mock
from unittest.mock import PropertyMock
@mock.patch(
'airflow.gcp.hooks.base.GoogleCloudBaseHook.project_id',
new_callable=PropertyMock,
return_value=''
)
@mock.patch("airflow.gcp.hooks.cloud_build.CloudBuildHook.get_conn")
@mock.patch("airflow.gcp.hooks.cloud_build.time.sleep")
def test_error_operation(self, _, get_conn_mock, mock_project_id):
pass |
Iiinteresting. If I run |
Here's a minimal repro case at least: import unittest
from unittest import mock
class TestCloudBuildHookWithPassedProjectId(unittest.TestCase):
@mock.patch(
'airflow.gcp.hooks.base.GoogleCloudBaseHook.project_id',
new_callable=mock.PropertyMock,
**{"return_value.classify_text.return_value": {}}
)
def test_error_operation(self, _, mock_project_id):
pass Oddly that seems to "leak" in to other files. This style of |
Filed as python/mypy#7572, where I have a repro that doesn't use typeshed stubs. Closing here. |
Airflow uses mypy and the latest update (0.730) started causing us errors, that I think are related to invalid typing on mock.patch.
(from https://github.com/apache/airflow/blob/2abf0f5b70970bcd16e8cf5846ba67cf3945ecae/tests/gcp/hooks/test_cloud_build.py#L118-L122)
Causes these errors:
(There are more examples of the same error in https://travis-ci.org/apache/airflow/jobs/590239664)
I'm not sure if this is a bug in the type definition or a bug in mypy itself.
The text was updated successfully, but these errors were encountered: