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 2022/07/21 10:57:27 UTC

[airflow] branch main updated: make MsSQL tests runnable on Python 3.8 (#25214)

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 911db9fc3f make MsSQL tests runnable on Python 3.8 (#25214)
911db9fc3f is described below

commit 911db9fc3f5940fd887f695fef9ccb2b3cb7e62a
Author: eladkal <45...@users.noreply.github.com>
AuthorDate: Thu Jul 21 13:57:19 2022 +0300

    make MsSQL tests runnable on Python 3.8 (#25214)
    
    mysql lib does support newer version of python https://github.com/pymssql/pymssql/pull/659
---
 tests/providers/google/cloud/transfers/test_mssql_to_gcs.py | 6 +-----
 tests/providers/microsoft/mssql/hooks/test_mssql.py         | 8 +-------
 tests/providers/microsoft/mssql/operators/test_mssql.py     | 9 ++-------
 3 files changed, 4 insertions(+), 19 deletions(-)

diff --git a/tests/providers/google/cloud/transfers/test_mssql_to_gcs.py b/tests/providers/google/cloud/transfers/test_mssql_to_gcs.py
index 8b9d820221..c84eed8d1f 100644
--- a/tests/providers/google/cloud/transfers/test_mssql_to_gcs.py
+++ b/tests/providers/google/cloud/transfers/test_mssql_to_gcs.py
@@ -22,10 +22,7 @@ from unittest import mock
 
 from parameterized import parameterized
 
-from airflow import PY38
-
-if not PY38:
-    from airflow.providers.google.cloud.transfers.mssql_to_gcs import MSSQLToGCSOperator
+from airflow.providers.google.cloud.transfers.mssql_to_gcs import MSSQLToGCSOperator
 
 TASK_ID = 'test-mssql-to-gcs'
 MSSQL_CONN_ID = 'mssql_conn_test'
@@ -51,7 +48,6 @@ SCHEMA_JSON = [
 ]
 
 
-@unittest.skipIf(PY38, "Mssql package not available when Python >= 3.8.")
 class TestMsSqlToGoogleCloudStorageOperator(unittest.TestCase):
     @parameterized.expand(
         [
diff --git a/tests/providers/microsoft/mssql/hooks/test_mssql.py b/tests/providers/microsoft/mssql/hooks/test_mssql.py
index 202c7f8749..cb3add3e94 100644
--- a/tests/providers/microsoft/mssql/hooks/test_mssql.py
+++ b/tests/providers/microsoft/mssql/hooks/test_mssql.py
@@ -19,17 +19,13 @@
 import unittest
 from unittest import mock
 
-from airflow import PY38
 from airflow.models import Connection
-
-if not PY38:
-    from airflow.providers.microsoft.mssql.hooks.mssql import MsSqlHook
+from airflow.providers.microsoft.mssql.hooks.mssql import MsSqlHook
 
 PYMSSQL_CONN = Connection(host='ip', schema='share', login='username', password='password', port=8081)
 
 
 class TestMsSqlHook(unittest.TestCase):
-    @unittest.skipIf(PY38, "Mssql package not available when Python >= 3.8.")
     @mock.patch('airflow.providers.microsoft.mssql.hooks.mssql.MsSqlHook.get_conn')
     @mock.patch('airflow.providers.common.sql.hooks.sql.DbApiHook.get_connection')
     def test_get_conn_should_return_connection(self, get_connection, mssql_get_conn):
@@ -42,7 +38,6 @@ class TestMsSqlHook(unittest.TestCase):
         assert mssql_get_conn.return_value == conn
         mssql_get_conn.assert_called_once()
 
-    @unittest.skipIf(PY38, "Mssql package not available when Python >= 3.8.")
     @mock.patch('airflow.providers.microsoft.mssql.hooks.mssql.MsSqlHook.get_conn')
     @mock.patch('airflow.providers.common.sql.hooks.sql.DbApiHook.get_connection')
     def test_set_autocommit_should_invoke_autocommit(self, get_connection, mssql_get_conn):
@@ -57,7 +52,6 @@ class TestMsSqlHook(unittest.TestCase):
         mssql_get_conn.assert_called_once()
         mssql_get_conn.return_value.autocommit.assert_called_once_with(autocommit_value)
 
-    @unittest.skipIf(PY38, "Mssql package not available when Python >= 3.8.")
     @mock.patch('airflow.providers.microsoft.mssql.hooks.mssql.MsSqlHook.get_conn')
     @mock.patch('airflow.providers.common.sql.hooks.sql.DbApiHook.get_connection')
     def test_get_autocommit_should_return_autocommit_state(self, get_connection, mssql_get_conn):
diff --git a/tests/providers/microsoft/mssql/operators/test_mssql.py b/tests/providers/microsoft/mssql/operators/test_mssql.py
index b0481a4ad9..979fcf8f6b 100644
--- a/tests/providers/microsoft/mssql/operators/test_mssql.py
+++ b/tests/providers/microsoft/mssql/operators/test_mssql.py
@@ -16,18 +16,14 @@
 # specific language governing permissions and limitations
 # under the License.
 
-import unittest
 from unittest import mock
 from unittest.mock import MagicMock, Mock
 
-from airflow import PY38, AirflowException
-
-if not PY38:
-    from airflow.providers.microsoft.mssql.operators.mssql import MsSqlOperator
+from airflow import AirflowException
+from airflow.providers.microsoft.mssql.operators.mssql import MsSqlOperator
 
 
 class TestMsSqlOperator:
-    @unittest.skipIf(PY38, "Mssql package not available when Python >= 3.8.")
     @mock.patch('airflow.hooks.base.BaseHook.get_connection')
     def test_get_hook_from_conn(self, get_connection):
         """
@@ -45,7 +41,6 @@ class TestMsSqlOperator:
         op = MsSqlOperator(task_id='test', sql='')
         assert op.get_hook() == mock_hook
 
-    @unittest.skipIf(PY38, "Mssql package not available when Python >= 3.8.")
     @mock.patch('airflow.hooks.base.BaseHook.get_connection')
     def test_get_hook_default(self, get_connection):
         """