From 11cf15f8dc5bf978f11807d4426216f8ca085b77 Mon Sep 17 00:00:00 2001 From: Karthikeyan Singaravelan Date: Fri, 26 Nov 2021 21:51:01 +0530 Subject: [PATCH] chore: Fix deprecated unittest aliases for Python 3.11 compatibility. (#17562) * chore: Fix deprecated unittest aliases for Python 3.11 compatibility. * chore: Cache pip dependencies. * chore: Cache more pip dependencies. --- .github/workflows/superset-python-integrationtest.yml | 9 +++++++++ .github/workflows/superset-python-misc.yml | 9 +++++++++ .github/workflows/superset-python-presto-hive.yml | 6 ++++++ .github/workflows/superset-python-unittest.yml | 3 +++ .../integration_tests/db_engine_specs/bigquery_tests.py | 2 +- tests/integration_tests/db_engine_specs/mssql_tests.py | 2 +- tests/integration_tests/security_tests.py | 4 ++-- 7 files changed, 31 insertions(+), 4 deletions(-) diff --git a/.github/workflows/superset-python-integrationtest.yml b/.github/workflows/superset-python-integrationtest.yml index 43ef9e7d2e129..a5a7705bcd88e 100644 --- a/.github/workflows/superset-python-integrationtest.yml +++ b/.github/workflows/superset-python-integrationtest.yml @@ -51,6 +51,8 @@ jobs: uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: 'requirements/testing.txt' - name: Install dependencies if: steps.check.outcome == 'failure' uses: ./.github/actions/cached-dependencies @@ -58,6 +60,7 @@ jobs: run: | apt-get-install pip-upgrade + pip install wheel pip install -r requirements/testing.txt setup-mysql - name: Run celery @@ -115,6 +118,8 @@ jobs: uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: 'requirements/testing.txt' - name: Install dependencies if: steps.check.outcome == 'failure' uses: ./.github/actions/cached-dependencies @@ -122,6 +127,7 @@ jobs: run: | apt-get-install pip-upgrade + pip install wheel pip install -r requirements/testing.txt setup-postgres - name: Run celery @@ -171,6 +177,8 @@ jobs: uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: 'requirements/testing.txt' - name: Install dependencies if: steps.check.outcome == 'failure' uses: ./.github/actions/cached-dependencies @@ -178,6 +186,7 @@ jobs: run: | apt-get-install pip-upgrade + pip install wheel pip install -r requirements/testing.txt mkdir ${{ github.workspace }}/.temp - name: Run celery diff --git a/.github/workflows/superset-python-misc.yml b/.github/workflows/superset-python-misc.yml index 4a38a95ee3a47..7f9ef14994b1f 100644 --- a/.github/workflows/superset-python-misc.yml +++ b/.github/workflows/superset-python-misc.yml @@ -33,6 +33,8 @@ jobs: uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: 'requirements/testing.txt' - name: Install dependencies if: steps.check.outcome == 'failure' uses: ./.github/actions/cached-dependencies @@ -40,6 +42,7 @@ jobs: run: | apt-get-install pip-upgrade + pip install wheel pip install -r requirements/testing.txt - name: pylint if: steps.check.outcome == 'failure' @@ -62,12 +65,15 @@ jobs: uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: 'requirements/integration.txt' - name: Install dependencies uses: ./.github/actions/cached-dependencies with: run: | apt-get-install pip-upgrade + pip install wheel pip install -r requirements/integration.txt - name: pre-commit run: pre-commit run --all-files @@ -88,12 +94,15 @@ jobs: uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: 'requirements/base.txt' - name: Install dependencies uses: ./.github/actions/cached-dependencies with: run: | apt-get-install pip-upgrade + pip install wheel pip install -r requirements/base.txt - name: Test babel extraction run: flask fab babel-extract --target superset/translations --output superset/translations/messages.pot --config superset/translations/babel.cfg -k _,__,t,tn,tct diff --git a/.github/workflows/superset-python-presto-hive.yml b/.github/workflows/superset-python-presto-hive.yml index 9177037822020..31043ea399378 100644 --- a/.github/workflows/superset-python-presto-hive.yml +++ b/.github/workflows/superset-python-presto-hive.yml @@ -62,6 +62,8 @@ jobs: uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: 'requirements/testing.txt' - name: Install dependencies if: steps.check.outcome == 'failure' uses: ./.github/actions/cached-dependencies @@ -69,6 +71,7 @@ jobs: run: | apt-get-install pip-upgrade + pip install wheel pip install -r requirements/testing.txt setup-postgres - name: Run celery @@ -137,6 +140,8 @@ jobs: uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: 'requirements/testing.txt' - name: Install dependencies if: steps.check.outcome == 'failure' uses: ./.github/actions/cached-dependencies @@ -144,6 +149,7 @@ jobs: run: | apt-get-install pip-upgrade + pip install wheel pip install -r requirements/testing.txt setup-postgres - name: Run celery diff --git a/.github/workflows/superset-python-unittest.yml b/.github/workflows/superset-python-unittest.yml index 8a64f092cb997..faf3f7265dd9a 100644 --- a/.github/workflows/superset-python-unittest.yml +++ b/.github/workflows/superset-python-unittest.yml @@ -35,6 +35,8 @@ jobs: uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: 'requirements/testing.txt' # TODO: separated requiermentes.txt file just for unit tests - name: Install dependencies if: steps.check.outcome == 'failure' @@ -43,6 +45,7 @@ jobs: run: | apt-get-install pip-upgrade + pip install wheel pip install -r requirements/testing.txt mkdir ${{ github.workspace }}/.temp - name: Python unit tests diff --git a/tests/integration_tests/db_engine_specs/bigquery_tests.py b/tests/integration_tests/db_engine_specs/bigquery_tests.py index ba6d0916fcd13..d3dd66df31bbb 100644 --- a/tests/integration_tests/db_engine_specs/bigquery_tests.py +++ b/tests/integration_tests/db_engine_specs/bigquery_tests.py @@ -200,7 +200,7 @@ def test_df_to_sql(self, mock_get_engine): # Test check for missing schema. sys.modules["google.oauth2"] = mock.MagicMock() for invalid_kwarg in invalid_kwargs: - self.assertRaisesRegexp( + self.assertRaisesRegex( Exception, "The table schema must be defined", BigQueryEngineSpec.df_to_sql, diff --git a/tests/integration_tests/db_engine_specs/mssql_tests.py b/tests/integration_tests/db_engine_specs/mssql_tests.py index 86310b60c13bd..7a8ee88c80c0d 100644 --- a/tests/integration_tests/db_engine_specs/mssql_tests.py +++ b/tests/integration_tests/db_engine_specs/mssql_tests.py @@ -40,7 +40,7 @@ def assert_type(type_string, type_expected, generic_type_expected): column_spec = MssqlEngineSpec.get_column_spec(type_string) if column_spec != None: self.assertIsInstance(column_spec.sqla_type, type_expected) - self.assertEquals(column_spec.generic_type, generic_type_expected) + self.assertEqual(column_spec.generic_type, generic_type_expected) assert_type("STRING", String, GenericDataType.STRING) assert_type("CHAR(10)", String, GenericDataType.STRING) diff --git a/tests/integration_tests/security_tests.py b/tests/integration_tests/security_tests.py index 7205077f33e9d..158b31662c937 100644 --- a/tests/integration_tests/security_tests.py +++ b/tests/integration_tests/security_tests.py @@ -467,13 +467,13 @@ def test_set_perm_slice(self): table.table_name = "tmp_perm_table_v2" session.commit() # TODO(bogdan): modify slice permissions on the table update. - self.assertNotEquals(slice.perm, table.perm) + self.assertNotEqual(slice.perm, table.perm) self.assertEqual(slice.perm, f"[tmp_database].[tmp_perm_table](id:{table.id})") self.assertEqual( table.perm, f"[tmp_database].[tmp_perm_table_v2](id:{table.id})" ) # TODO(bogdan): modify slice schema permissions on the table update. - self.assertNotEquals(slice.schema_perm, table.schema_perm) + self.assertNotEqual(slice.schema_perm, table.schema_perm) self.assertIsNone(slice.schema_perm) # updating slice refreshes the permissions