From 4e340c83687f9fffec00c939c29397ee85abd231 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Mon, 29 Jun 2020 15:36:06 -0700 Subject: [PATCH] feat: Switch from nosetest to pytest (#10177) * Switch from nosetest to pytest Fix schedule tests Collect pytest coverage Move pytest config into pytest.ini Move cov to the pytest.ini * Append coverage for the 2nd run * Add coverage to all commands * Coverage only for tests * Get coverage from 1 place * Rename classes to be pytest compatible * Test coverage for examples and tests * Max diff to -1 * Explain how to run pytest for the whole project * Do not append code coverage for the main run * Do not run coverage on examples Co-authored-by: bogdan kyryliuk --- pytest.ini | 21 +++++++++++++++++++ requirements-dev.txt | 3 ++- scripts/python_tests.sh | 4 ++-- scripts/tests/run.sh | 4 ++-- setup.cfg | 7 ------- tests/access_tests.py | 4 +++- tests/base_api_tests.py | 2 +- tests/base_tests.py | 4 +--- tests/cache_tests.py | 5 +---- tests/celery_tests.py | 6 +++--- tests/charts/api_tests.py | 5 +---- tests/charts/schema_tests.py | 2 +- tests/config_tests.py | 5 +---- tests/core_tests.py | 5 +---- tests/dashboard_tests.py | 2 +- tests/dashboards/api_tests.py | 5 +---- tests/dashboards/dao_tests.py | 2 +- tests/database_api_tests.py | 2 +- tests/dataframe_test.py | 2 +- tests/datasets/api_tests.py | 2 +- tests/datasource_tests.py | 5 +---- tests/db_engine_specs/athena_tests.py | 4 ++-- .../db_engine_specs/base_engine_spec_tests.py | 4 ++-- tests/db_engine_specs/base_tests.py | 2 +- tests/db_engine_specs/bigquery_tests.py | 4 ++-- tests/db_engine_specs/clickhouse_tests.py | 4 ++-- tests/db_engine_specs/drill_tests.py | 4 ++-- tests/db_engine_specs/druid_tests.py | 4 ++-- tests/db_engine_specs/elasticsearch_tests.py | 4 ++-- tests/db_engine_specs/hive_tests.py | 4 ++-- tests/db_engine_specs/impala_tests.py | 4 ++-- tests/db_engine_specs/kylin_tests.py | 4 ++-- tests/db_engine_specs/mssql_tests.py | 4 ++-- tests/db_engine_specs/mysql_tests.py | 6 +++--- tests/db_engine_specs/oracle_tests.py | 4 ++-- tests/db_engine_specs/pinot_tests.py | 4 ++-- tests/db_engine_specs/postgres_tests.py | 4 ++-- tests/db_engine_specs/presto_tests.py | 8 +++---- tests/db_engine_specs/snowflake_tests.py | 4 ++-- tests/db_engine_specs/sqlite_tests.py | 4 ++-- tests/dict_import_export_tests.py | 5 +---- tests/druid_func_tests.py | 2 +- tests/druid_func_tests_sip38.py | 2 +- tests/druid_tests.py | 2 +- tests/email_tests.py | 2 +- tests/feature_flag_tests.py | 2 +- tests/form_tests.py | 2 +- tests/import_export_tests.py | 2 +- tests/jinja_context_tests.py | 2 +- tests/load_examples_test.py | 6 +----- tests/log_api_tests.py | 2 +- tests/migration_tests.py | 2 +- tests/model_tests.py | 4 ++-- tests/pandas_postprocessing_tests.py | 2 +- tests/queries/api_tests.py | 2 +- tests/query_context_tests.py | 2 +- tests/result_set_tests.py | 2 +- tests/schedules_test.py | 10 ++++----- tests/security/analytics_db_safety_tests.py | 2 +- tests/security_tests.py | 6 +++--- tests/sql_parse_tests.py | 2 +- tests/sql_validator_tests.py | 6 +++--- tests/sqla_models_tests.py | 2 +- tests/sqllab_tests.py | 5 +---- tests/stats_logger_tests.py | 2 +- tests/strategy_tests.py | 5 +---- tests/tagging_tests.py | 2 +- tests/thumbnails_tests.py | 4 ++-- tests/utils_tests.py | 2 +- tests/viz_tests.py | 20 +++++++++--------- tox.ini | 6 ++++-- 71 files changed, 139 insertions(+), 155 deletions(-) create mode 100644 pytest.ini diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000000000..418efb2566a0c --- /dev/null +++ b/pytest.ini @@ -0,0 +1,21 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +[pytest] +addopts = -ra -q +testpaths = + tests +python_files = *_test.py test_*.py *_tests.py diff --git a/requirements-dev.txt b/requirements-dev.txt index 3687aff93736b..399f9b7417335 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -21,7 +21,8 @@ flask-testing==0.8.0 ipdb==0.12 isort==4.3.21 mypy==0.770 -nose==1.3.7 +pytest==5.4.3 +pytest-cov==2.10.0 parameterized==0.7.4 pip-tools==5.1.2 pre-commit==1.17.0 diff --git a/scripts/python_tests.sh b/scripts/python_tests.sh index 33768af3156a0..f0309f2a9f68d 100755 --- a/scripts/python_tests.sh +++ b/scripts/python_tests.sh @@ -23,5 +23,5 @@ echo "Superset config module: $SUPERSET_CONFIG" superset db upgrade superset init -nosetests --stop tests/load_examples_test.py -nosetests --stop --exclude=load_examples_test tests +pytest --maxfail=1 tests/load_examples_test.py +pytest --maxfail=1 --cov=superset --ignore=load_examples_test tests/* diff --git a/scripts/tests/run.sh b/scripts/tests/run.sh index 5e9566352c66f..aeffeb0d2da04 100755 --- a/scripts/tests/run.sh +++ b/scripts/tests/run.sh @@ -56,7 +56,7 @@ function test_init() { echo -------------------- echo Load examples echo -------------------- - nosetests tests/load_examples_test.py + pytest -s tests/load_examples_test.py } @@ -145,5 +145,5 @@ fi if [ $RUN_TESTS -eq 1 ] then - nosetests --exclude=load_examples_test "${TEST_MODULE}" + pytest -s --ignore=load_examples_test "${TEST_MODULE}" fi diff --git a/setup.cfg b/setup.cfg index e7eedf76a3097..8c969faa7f7be 100644 --- a/setup.cfg +++ b/setup.cfg @@ -33,13 +33,6 @@ all_files = 1 [upload_sphinx] upload-dir = docs/_build/html -[nosetests] -verbosity = 3 -detailed-errors = 1 -with-coverage = 1 -nocapture = 1 -cover-package = superset - [isort] combine_as_imports = true include_trailing_comma = true diff --git a/tests/access_tests.py b/tests/access_tests.py index 0af7415293b76..d452d13aa576a 100644 --- a/tests/access_tests.py +++ b/tests/access_tests.py @@ -94,10 +94,12 @@ def create_access_request(session, ds_type, ds_name, role_name, user_name): return access_request -class RequestAccessTests(SupersetTestCase): +class TestRequestAccess(SupersetTestCase): @classmethod def setUpClass(cls): with app.app_context(): + cls.create_druid_test_objects() + security_manager.add_role("override_me") security_manager.add_role(TEST_ROLE_1) security_manager.add_role(TEST_ROLE_2) diff --git a/tests/base_api_tests.py b/tests/base_api_tests.py index 112211abb50e1..e1f6e4893b2a2 100644 --- a/tests/base_api_tests.py +++ b/tests/base_api_tests.py @@ -48,7 +48,7 @@ class Model1Api(BaseSupersetModelRestApi): appbuilder.add_api(Model1Api) -class BaseModelRestApiTests(SupersetTestCase): +class TestBaseModelRestApi(SupersetTestCase): def test_default_missing_declaration_get(self): """ API: Test default missing declaration on get diff --git a/tests/base_tests.py b/tests/base_tests.py index 28895fe061d41..871480bfa038b 100644 --- a/tests/base_tests.py +++ b/tests/base_tests.py @@ -52,9 +52,7 @@ class SupersetTestCase(TestCase): "postgresql": "public", } - def __init__(self, *args, **kwargs): - super(SupersetTestCase, self).__init__(*args, **kwargs) - self.maxDiff = None + maxDiff = -1 def create_app(self): return app diff --git a/tests/cache_tests.py b/tests/cache_tests.py index 3a889fa0d06f0..4f6581ca9b791 100644 --- a/tests/cache_tests.py +++ b/tests/cache_tests.py @@ -23,10 +23,7 @@ from .base_tests import SupersetTestCase -class CacheTests(SupersetTestCase): - def __init__(self, *args, **kwargs): - super(CacheTests, self).__init__(*args, **kwargs) - +class TestCache(SupersetTestCase): def setUp(self): cache.clear() diff --git a/tests/celery_tests.py b/tests/celery_tests.py index e30d7807f9284..af20de6ebab57 100644 --- a/tests/celery_tests.py +++ b/tests/celery_tests.py @@ -44,7 +44,7 @@ DROP_TABLE_SLEEP_TIME = 10 -class UtilityFunctionTests(SupersetTestCase): +class TestUtilityFunction(SupersetTestCase): # TODO(bkyryliuk): support more cases in CTA function. def test_create_table_as(self): q = ParsedQuery("SELECT * FROM outer_space;") @@ -75,7 +75,7 @@ def test_create_table_as(self): ) -class AppContextTests(SupersetTestCase): +class TestAppContext(SupersetTestCase): def test_in_app_context(self): @celery_app.task() def my_task(): @@ -95,7 +95,7 @@ def my_task(): CTAS_SCHEMA_NAME = "sqllab_test_db" -class CeleryTestCase(SupersetTestCase): +class TestCelery(SupersetTestCase): def get_query_by_name(self, sql): session = db.session query = session.query(Query).filter_by(sql=sql).first() diff --git a/tests/charts/api_tests.py b/tests/charts/api_tests.py index 2723bcd1d6f46..24aa1e8496761 100644 --- a/tests/charts/api_tests.py +++ b/tests/charts/api_tests.py @@ -36,12 +36,9 @@ CHART_DATA_URI = "api/v1/chart/data" -class ChartApiTests(SupersetTestCase, ApiOwnersTestCaseMixin): +class TestChartApi(SupersetTestCase, ApiOwnersTestCaseMixin): resource_name = "chart" - def __init__(self, *args, **kwargs): - super(ChartApiTests, self).__init__(*args, **kwargs) - def insert_chart( self, slice_name: str, diff --git a/tests/charts/schema_tests.py b/tests/charts/schema_tests.py index fc51d02a83892..4c998fc27abf4 100644 --- a/tests/charts/schema_tests.py +++ b/tests/charts/schema_tests.py @@ -29,7 +29,7 @@ def load_query_context(payload: Dict[str, Any]) -> Tuple[QueryContext, Dict[str, return ChartDataQueryContextSchema().load(payload) -class SchemaTestCase(SupersetTestCase): +class TestSchema(SupersetTestCase): def test_query_context_limit_and_offset(self): self.login(username="admin") table_name = "birth_names" diff --git a/tests/config_tests.py b/tests/config_tests.py index 851bb6bddf497..1c661b5eac227 100644 --- a/tests/config_tests.py +++ b/tests/config_tests.py @@ -71,10 +71,7 @@ def apply_dttm_defaults(table: SqlaTable, dttm_defaults: Dict[str, Any]): dbcol.expression = dttm_column_defaults["expression"] -class ConfigTests(SupersetTestCase): - def __init__(self, *args, **kwargs): - super(ConfigTests, self).__init__(*args, **kwargs) - +class TestConfig(SupersetTestCase): def setUp(self) -> None: self.login(username="admin") self._test_db_id = get_or_create_db( diff --git a/tests/core_tests.py b/tests/core_tests.py index fde253e47bf1a..e67a84632061d 100644 --- a/tests/core_tests.py +++ b/tests/core_tests.py @@ -67,10 +67,7 @@ logger = logging.getLogger(__name__) -class CoreTests(SupersetTestCase): - def __init__(self, *args, **kwargs): - super(CoreTests, self).__init__(*args, **kwargs) - +class TestCore(SupersetTestCase): def setUp(self): db.session.query(Query).delete() db.session.query(DatasourceAccessRequest).delete() diff --git a/tests/dashboard_tests.py b/tests/dashboard_tests.py index 3afbbe42bf009..50db6d03c1061 100644 --- a/tests/dashboard_tests.py +++ b/tests/dashboard_tests.py @@ -35,7 +35,7 @@ from .base_tests import SupersetTestCase -class DashboardTests(SupersetTestCase): +class TestDashboard(SupersetTestCase): def get_mock_positions(self, dash): positions = {"DASHBOARD_VERSION_KEY": "v2"} for i, slc in enumerate(dash.slices): diff --git a/tests/dashboards/api_tests.py b/tests/dashboards/api_tests.py index 23cdd882faf9c..145706c784a57 100644 --- a/tests/dashboards/api_tests.py +++ b/tests/dashboards/api_tests.py @@ -32,7 +32,7 @@ from tests.base_tests import SupersetTestCase -class DashboardApiTests(SupersetTestCase, ApiOwnersTestCaseMixin): +class TestDashboardApi(SupersetTestCase, ApiOwnersTestCaseMixin): resource_name = "dashboard" dashboard_data = { @@ -44,9 +44,6 @@ class DashboardApiTests(SupersetTestCase, ApiOwnersTestCaseMixin): "published": False, } - def __init__(self, *args, **kwargs): - super(DashboardApiTests, self).__init__(*args, **kwargs) - def insert_dashboard( self, dashboard_title: str, diff --git a/tests/dashboards/dao_tests.py b/tests/dashboards/dao_tests.py index 8d3c51c07aeb3..6bb22b885ba8e 100644 --- a/tests/dashboards/dao_tests.py +++ b/tests/dashboards/dao_tests.py @@ -25,7 +25,7 @@ from tests.base_tests import SupersetTestCase -class DashboardDAOTests(SupersetTestCase): +class TestDashboardDAO(SupersetTestCase): def test_set_dash_metadata(self): dash = db.session.query(Dashboard).filter_by(slug="world_health").first() data = dash.data diff --git a/tests/database_api_tests.py b/tests/database_api_tests.py index d0e9ecf541351..2cb2d437c0fc1 100644 --- a/tests/database_api_tests.py +++ b/tests/database_api_tests.py @@ -30,7 +30,7 @@ from .base_tests import SupersetTestCase -class DatabaseApiTests(SupersetTestCase): +class TestDatabaseApi(SupersetTestCase): def test_get_items(self): """ Database API: Test get items diff --git a/tests/dataframe_test.py b/tests/dataframe_test.py index fdb0207bba8cd..a6dbbac3014ed 100644 --- a/tests/dataframe_test.py +++ b/tests/dataframe_test.py @@ -26,7 +26,7 @@ from .base_tests import SupersetTestCase -class SupersetDataFrameTestCase(SupersetTestCase): +class TestSupersetDataFrame(SupersetTestCase): def test_df_to_records(self): data = [("a1", "b1", "c1"), ("a2", "b2", "c2")] cursor_descr = (("a", "string"), ("b", "string"), ("c", "string")) diff --git a/tests/datasets/api_tests.py b/tests/datasets/api_tests.py index 184b7840da18c..e1d642ff8a39e 100644 --- a/tests/datasets/api_tests.py +++ b/tests/datasets/api_tests.py @@ -38,7 +38,7 @@ from tests.base_tests import SupersetTestCase -class DatasetApiTests(SupersetTestCase): +class TestDatasetApi(SupersetTestCase): @staticmethod def insert_dataset( table_name: str, schema: str, owners: List[int], database: Database diff --git a/tests/datasource_tests.py b/tests/datasource_tests.py index 9015e6d01b80c..8733059334dd1 100644 --- a/tests/datasource_tests.py +++ b/tests/datasource_tests.py @@ -24,10 +24,7 @@ from .fixtures.datasource import datasource_post -class DatasourceTests(SupersetTestCase): - def __init__(self, *args, **kwargs): - super(DatasourceTests, self).__init__(*args, **kwargs) - +class TestDatasource(SupersetTestCase): def test_external_metadata(self): self.login(username="admin") tbl = self.get_table_by_name("birth_names") diff --git a/tests/db_engine_specs/athena_tests.py b/tests/db_engine_specs/athena_tests.py index b59f50076fb7c..92160dbd066e9 100644 --- a/tests/db_engine_specs/athena_tests.py +++ b/tests/db_engine_specs/athena_tests.py @@ -17,10 +17,10 @@ from tests.test_app import app # isort:skip from superset.db_engine_specs.athena import AthenaEngineSpec -from tests.db_engine_specs.base_tests import DbEngineSpecTestCase +from tests.db_engine_specs.base_tests import TestDbEngineSpec -class AthenaTestCase(DbEngineSpecTestCase): +class TestAthenaDbEngineSpec(TestDbEngineSpec): def test_convert_dttm(self): dttm = self.get_dttm() diff --git a/tests/db_engine_specs/base_engine_spec_tests.py b/tests/db_engine_specs/base_engine_spec_tests.py index 1d68e981bc3a0..f4fc64ba58531 100644 --- a/tests/db_engine_specs/base_engine_spec_tests.py +++ b/tests/db_engine_specs/base_engine_spec_tests.py @@ -23,12 +23,12 @@ from superset.db_engine_specs.base import BaseEngineSpec, builtin_time_grains from superset.db_engine_specs.sqlite import SqliteEngineSpec from superset.utils.core import get_example_database -from tests.db_engine_specs.base_tests import DbEngineSpecTestCase +from tests.db_engine_specs.base_tests import TestDbEngineSpec from ..fixtures.pyodbcRow import Row -class DbEngineSpecsTests(DbEngineSpecTestCase): +class TestDbEngineSpecs(TestDbEngineSpec): def test_extract_limit_from_query(self, engine_spec_class=BaseEngineSpec): q0 = "select * from table" q1 = "select * from mytable limit 10" diff --git a/tests/db_engine_specs/base_tests.py b/tests/db_engine_specs/base_tests.py index 5b08dbf7793be..9df91f4b18dab 100644 --- a/tests/db_engine_specs/base_tests.py +++ b/tests/db_engine_specs/base_tests.py @@ -23,7 +23,7 @@ from tests.test_app import app # isort:skip -class DbEngineSpecTestCase(SupersetTestCase): +class TestDbEngineSpec(SupersetTestCase): def sql_limit_regex( self, sql, expected_sql, engine_spec_class=MySQLEngineSpec, limit=1000 ): diff --git a/tests/db_engine_specs/bigquery_tests.py b/tests/db_engine_specs/bigquery_tests.py index 67f77479547c9..988575dffceb4 100644 --- a/tests/db_engine_specs/bigquery_tests.py +++ b/tests/db_engine_specs/bigquery_tests.py @@ -22,10 +22,10 @@ from superset.db_engine_specs.base import BaseEngineSpec from superset.db_engine_specs.bigquery import BigQueryEngineSpec -from tests.db_engine_specs.base_tests import DbEngineSpecTestCase +from tests.db_engine_specs.base_tests import TestDbEngineSpec -class BigQueryTestCase(DbEngineSpecTestCase): +class TestBigQueryDbEngineSpec(TestDbEngineSpec): def test_bigquery_sqla_column_label(self): """ DB Eng Specs (bigquery): Test column label diff --git a/tests/db_engine_specs/clickhouse_tests.py b/tests/db_engine_specs/clickhouse_tests.py index 5c06a395959d6..b6416c8d0c8ed 100644 --- a/tests/db_engine_specs/clickhouse_tests.py +++ b/tests/db_engine_specs/clickhouse_tests.py @@ -15,10 +15,10 @@ # specific language governing permissions and limitations # under the License. from superset.db_engine_specs.clickhouse import ClickHouseEngineSpec -from tests.db_engine_specs.base_tests import DbEngineSpecTestCase +from tests.db_engine_specs.base_tests import TestDbEngineSpec -class ClickHouseTestCase(DbEngineSpecTestCase): +class TestClickHouseDbEngineSpec(TestDbEngineSpec): def test_convert_dttm(self): dttm = self.get_dttm() diff --git a/tests/db_engine_specs/drill_tests.py b/tests/db_engine_specs/drill_tests.py index 0e64f027708b2..9897a5dcccd3b 100644 --- a/tests/db_engine_specs/drill_tests.py +++ b/tests/db_engine_specs/drill_tests.py @@ -15,10 +15,10 @@ # specific language governing permissions and limitations # under the License. from superset.db_engine_specs.drill import DrillEngineSpec -from tests.db_engine_specs.base_tests import DbEngineSpecTestCase +from tests.db_engine_specs.base_tests import TestDbEngineSpec -class DrillTestCase(DbEngineSpecTestCase): +class TestDrillDbEngineSpec(TestDbEngineSpec): def test_convert_dttm(self): dttm = self.get_dttm() diff --git a/tests/db_engine_specs/druid_tests.py b/tests/db_engine_specs/druid_tests.py index 76f49e95674fc..fb9f3f4d34c37 100644 --- a/tests/db_engine_specs/druid_tests.py +++ b/tests/db_engine_specs/druid_tests.py @@ -17,10 +17,10 @@ from sqlalchemy import column from superset.db_engine_specs.druid import DruidEngineSpec -from tests.db_engine_specs.base_tests import DbEngineSpecTestCase +from tests.db_engine_specs.base_tests import TestDbEngineSpec -class DruidTestCase(DbEngineSpecTestCase): +class TestDruidDbEngineSpec(TestDbEngineSpec): def test_convert_dttm(self): dttm = self.get_dttm() diff --git a/tests/db_engine_specs/elasticsearch_tests.py b/tests/db_engine_specs/elasticsearch_tests.py index 8b222a67a0740..30fa14ca93ec1 100644 --- a/tests/db_engine_specs/elasticsearch_tests.py +++ b/tests/db_engine_specs/elasticsearch_tests.py @@ -15,10 +15,10 @@ # specific language governing permissions and limitations # under the License. from superset.db_engine_specs.elasticsearch import ElasticSearchEngineSpec -from tests.db_engine_specs.base_tests import DbEngineSpecTestCase +from tests.db_engine_specs.base_tests import TestDbEngineSpec -class ElasticSearchTestCase(DbEngineSpecTestCase): +class TestElasticSearchDbEngineSpec(TestDbEngineSpec): def test_convert_dttm(self): dttm = self.get_dttm() diff --git a/tests/db_engine_specs/hive_tests.py b/tests/db_engine_specs/hive_tests.py index 1ac6ddc9d2a6d..83b23e994bc75 100644 --- a/tests/db_engine_specs/hive_tests.py +++ b/tests/db_engine_specs/hive_tests.py @@ -19,10 +19,10 @@ from superset.db_engine_specs.hive import HiveEngineSpec from superset.exceptions import SupersetException from superset.sql_parse import Table -from tests.db_engine_specs.base_tests import DbEngineSpecTestCase +from tests.db_engine_specs.base_tests import TestDbEngineSpec -class HiveTests(DbEngineSpecTestCase): +class TestHiveDbEngineSpec(TestDbEngineSpec): def test_0_progress(self): log = """ 17/02/07 18:26:27 INFO log.PerfLogger: diff --git a/tests/db_engine_specs/impala_tests.py b/tests/db_engine_specs/impala_tests.py index c0de4f25de3d3..8d2e40392b05c 100644 --- a/tests/db_engine_specs/impala_tests.py +++ b/tests/db_engine_specs/impala_tests.py @@ -15,10 +15,10 @@ # specific language governing permissions and limitations # under the License. from superset.db_engine_specs.impala import ImpalaEngineSpec -from tests.db_engine_specs.base_tests import DbEngineSpecTestCase +from tests.db_engine_specs.base_tests import TestDbEngineSpec -class ImpalaTestCase(DbEngineSpecTestCase): +class TestImpalaDbEngineSpec(TestDbEngineSpec): def test_convert_dttm(self): dttm = self.get_dttm() diff --git a/tests/db_engine_specs/kylin_tests.py b/tests/db_engine_specs/kylin_tests.py index 2301e30eee904..8e6c0204d0185 100644 --- a/tests/db_engine_specs/kylin_tests.py +++ b/tests/db_engine_specs/kylin_tests.py @@ -15,10 +15,10 @@ # specific language governing permissions and limitations # under the License. from superset.db_engine_specs.kylin import KylinEngineSpec -from tests.db_engine_specs.base_tests import DbEngineSpecTestCase +from tests.db_engine_specs.base_tests import TestDbEngineSpec -class KylinTestCase(DbEngineSpecTestCase): +class TestKylinDbEngineSpec(TestDbEngineSpec): def test_convert_dttm(self): dttm = self.get_dttm() diff --git a/tests/db_engine_specs/mssql_tests.py b/tests/db_engine_specs/mssql_tests.py index 0a254de026a81..149ed692c93ed 100644 --- a/tests/db_engine_specs/mssql_tests.py +++ b/tests/db_engine_specs/mssql_tests.py @@ -24,10 +24,10 @@ from superset.db_engine_specs.base import BaseEngineSpec from superset.db_engine_specs.mssql import MssqlEngineSpec -from tests.db_engine_specs.base_tests import DbEngineSpecTestCase +from tests.db_engine_specs.base_tests import TestDbEngineSpec -class MssqlEngineSpecTest(DbEngineSpecTestCase): +class TestMssqlEngineSpec(TestDbEngineSpec): def test_mssql_column_types(self): def assert_type(type_string, type_expected): type_assigned = MssqlEngineSpec.get_sqla_column_type(type_string) diff --git a/tests/db_engine_specs/mysql_tests.py b/tests/db_engine_specs/mysql_tests.py index 897507d5decea..f284f8801ad06 100644 --- a/tests/db_engine_specs/mysql_tests.py +++ b/tests/db_engine_specs/mysql_tests.py @@ -20,12 +20,12 @@ from sqlalchemy.dialects.mysql import DATE, NVARCHAR, TEXT, VARCHAR from superset.db_engine_specs.mysql import MySQLEngineSpec -from tests.db_engine_specs.base_tests import DbEngineSpecTestCase +from tests.db_engine_specs.base_tests import TestDbEngineSpec -class MySQLEngineSpecsTestCase(DbEngineSpecTestCase): +class TestMySQLEngineSpecsDbEngineSpec(TestDbEngineSpec): @unittest.skipUnless( - DbEngineSpecTestCase.is_module_installed("MySQLdb"), "mysqlclient not installed" + TestDbEngineSpec.is_module_installed("MySQLdb"), "mysqlclient not installed" ) def test_get_datatype_mysql(self): """Tests related to datatype mapping for MySQL""" diff --git a/tests/db_engine_specs/oracle_tests.py b/tests/db_engine_specs/oracle_tests.py index 8b821c749815e..1aa375d1f408b 100644 --- a/tests/db_engine_specs/oracle_tests.py +++ b/tests/db_engine_specs/oracle_tests.py @@ -19,10 +19,10 @@ from sqlalchemy.dialects.oracle import DATE, NVARCHAR, VARCHAR from superset.db_engine_specs.oracle import OracleEngineSpec -from tests.db_engine_specs.base_tests import DbEngineSpecTestCase +from tests.db_engine_specs.base_tests import TestDbEngineSpec -class OracleTestCase(DbEngineSpecTestCase): +class TestOracleDbEngineSpec(TestDbEngineSpec): def test_oracle_sqla_column_name_length_exceeded(self): col = column("This_Is_32_Character_Column_Name") label = OracleEngineSpec.make_label_compatible(col.name) diff --git a/tests/db_engine_specs/pinot_tests.py b/tests/db_engine_specs/pinot_tests.py index 405ac9b161672..973282737b2de 100644 --- a/tests/db_engine_specs/pinot_tests.py +++ b/tests/db_engine_specs/pinot_tests.py @@ -17,10 +17,10 @@ from sqlalchemy import column from superset.db_engine_specs.pinot import PinotEngineSpec -from tests.db_engine_specs.base_tests import DbEngineSpecTestCase +from tests.db_engine_specs.base_tests import TestDbEngineSpec -class PinotTestCase(DbEngineSpecTestCase): +class TestPinotDbEngineSpec(TestDbEngineSpec): """ Tests pertaining to our Pinot database support """ def test_pinot_time_expression_sec_one_1m_grain(self): diff --git a/tests/db_engine_specs/postgres_tests.py b/tests/db_engine_specs/postgres_tests.py index 098e918685318..139b33982e758 100644 --- a/tests/db_engine_specs/postgres_tests.py +++ b/tests/db_engine_specs/postgres_tests.py @@ -20,10 +20,10 @@ from sqlalchemy.dialects import postgresql from superset.db_engine_specs.postgres import PostgresEngineSpec -from tests.db_engine_specs.base_tests import DbEngineSpecTestCase +from tests.db_engine_specs.base_tests import TestDbEngineSpec -class PostgresTests(DbEngineSpecTestCase): +class TestPostgresDbEngineSpec(TestDbEngineSpec): def test_get_table_names(self): """ DB Eng Specs (postgres): Test get table names diff --git a/tests/db_engine_specs/presto_tests.py b/tests/db_engine_specs/presto_tests.py index 0ca06359a0461..b57ab01b18e96 100644 --- a/tests/db_engine_specs/presto_tests.py +++ b/tests/db_engine_specs/presto_tests.py @@ -21,13 +21,11 @@ from sqlalchemy.sql import select from superset.db_engine_specs.presto import PrestoEngineSpec -from tests.db_engine_specs.base_tests import DbEngineSpecTestCase +from tests.db_engine_specs.base_tests import TestDbEngineSpec -class PrestoTests(DbEngineSpecTestCase): - @skipUnless( - DbEngineSpecTestCase.is_module_installed("pyhive"), "pyhive not installed" - ) +class TestPrestoDbEngineSpec(TestDbEngineSpec): + @skipUnless(TestDbEngineSpec.is_module_installed("pyhive"), "pyhive not installed") def test_get_datatype_presto(self): self.assertEqual("STRING", PrestoEngineSpec.get_datatype("string")) diff --git a/tests/db_engine_specs/snowflake_tests.py b/tests/db_engine_specs/snowflake_tests.py index 027e37394d6d4..e8f76fe7b6fc8 100644 --- a/tests/db_engine_specs/snowflake_tests.py +++ b/tests/db_engine_specs/snowflake_tests.py @@ -18,10 +18,10 @@ from superset.db_engine_specs.snowflake import SnowflakeEngineSpec from superset.models.core import Database -from tests.db_engine_specs.base_tests import DbEngineSpecTestCase +from tests.db_engine_specs.base_tests import TestDbEngineSpec -class SnowflakeTestCase(DbEngineSpecTestCase): +class TestSnowflakeDbEngineSpec(TestDbEngineSpec): def test_convert_dttm(self): dttm = self.get_dttm() diff --git a/tests/db_engine_specs/sqlite_tests.py b/tests/db_engine_specs/sqlite_tests.py index 71104c47d1555..fd3001cdefe0d 100644 --- a/tests/db_engine_specs/sqlite_tests.py +++ b/tests/db_engine_specs/sqlite_tests.py @@ -15,10 +15,10 @@ # specific language governing permissions and limitations # under the License. from superset.db_engine_specs.sqlite import SqliteEngineSpec -from tests.db_engine_specs.base_tests import DbEngineSpecTestCase +from tests.db_engine_specs.base_tests import TestDbEngineSpec -class SQliteTestCase(DbEngineSpecTestCase): +class TestSQliteDbEngineSpec(TestDbEngineSpec): def test_convert_dttm(self): dttm = self.get_dttm() diff --git a/tests/dict_import_export_tests.py b/tests/dict_import_export_tests.py index 3597eac3eae47..dc0b8d8d875a4 100644 --- a/tests/dict_import_export_tests.py +++ b/tests/dict_import_export_tests.py @@ -40,12 +40,9 @@ ID_PREFIX = 20000 -class DictImportExportTests(SupersetTestCase): +class TestDictImportExport(SupersetTestCase): """Testing export import functionality for dashboards""" - def __init__(self, *args, **kwargs): - super(DictImportExportTests, self).__init__(*args, **kwargs) - @classmethod def delete_imports(cls): with app.app_context(): diff --git a/tests/druid_func_tests.py b/tests/druid_func_tests.py index 699afeaec8352..a8b16922f557d 100644 --- a/tests/druid_func_tests.py +++ b/tests/druid_func_tests.py @@ -50,7 +50,7 @@ def emplace(metrics_dict, metric_name, is_postagg=False): # Unit tests that can be run without initializing base tests -class DruidFuncTestCase(SupersetTestCase): +class TestDruidFunc(SupersetTestCase): @unittest.skipUnless( SupersetTestCase.is_module_installed("pydruid"), "pydruid not installed" ) diff --git a/tests/druid_func_tests_sip38.py b/tests/druid_func_tests_sip38.py index 058d8c1743bd7..fb2837e70a11d 100644 --- a/tests/druid_func_tests_sip38.py +++ b/tests/druid_func_tests_sip38.py @@ -55,7 +55,7 @@ def emplace(metrics_dict, metric_name, is_postagg=False): {"SIP_38_VIZ_REARCHITECTURE": True}, clear=True, ) -class DruidFuncTestCase(SupersetTestCase): +class TestDruidFunc(SupersetTestCase): @unittest.skipUnless( SupersetTestCase.is_module_installed("pydruid"), "pydruid not installed" ) diff --git a/tests/druid_tests.py b/tests/druid_tests.py index c0d18340ff7e7..648eb32ccbd54 100644 --- a/tests/druid_tests.py +++ b/tests/druid_tests.py @@ -102,7 +102,7 @@ def __reduce__(self): DruidCluster.get_druid_version = lambda _: "0.9.1" # type: ignore -class DruidTests(SupersetTestCase): +class TestDruid(SupersetTestCase): """Testing interactions with Druid""" diff --git a/tests/email_tests.py b/tests/email_tests.py index 59af211fbe7b2..94337f6831d5a 100644 --- a/tests/email_tests.py +++ b/tests/email_tests.py @@ -34,7 +34,7 @@ logger = logging.getLogger(__name__) -class EmailSmtpTest(SupersetTestCase): +class TestEmailSmtp(SupersetTestCase): def setUp(self): app.config["smtp_ssl"] = False diff --git a/tests/feature_flag_tests.py b/tests/feature_flag_tests.py index 8712c63657d44..2ce9649be579a 100644 --- a/tests/feature_flag_tests.py +++ b/tests/feature_flag_tests.py @@ -20,7 +20,7 @@ from tests.base_tests import SupersetTestCase -class FeatureFlagTests(SupersetTestCase): +class TestFeatureFlag(SupersetTestCase): @patch.dict( "superset.extensions.feature_flag_manager._feature_flags", {"FOO": True}, diff --git a/tests/form_tests.py b/tests/form_tests.py index 2ac143dba024a..92aea641ce453 100644 --- a/tests/form_tests.py +++ b/tests/form_tests.py @@ -20,7 +20,7 @@ from tests.base_tests import SupersetTestCase -class FormTestCase(SupersetTestCase): +class TestForm(SupersetTestCase): def test_comma_separated_list_field(self): field = CommaSeparatedListField().bind(Form(), "foo") field.process_formdata([u""]) diff --git a/tests/import_export_tests.py b/tests/import_export_tests.py index b47b43b264f18..16443afa2317e 100644 --- a/tests/import_export_tests.py +++ b/tests/import_export_tests.py @@ -38,7 +38,7 @@ from .base_tests import SupersetTestCase -class ImportExportTests(SupersetTestCase): +class TestImportExport(SupersetTestCase): """Testing export import functionality for dashboards""" @classmethod diff --git a/tests/jinja_context_tests.py b/tests/jinja_context_tests.py index 431d3b67f2083..0f15b113bf51b 100644 --- a/tests/jinja_context_tests.py +++ b/tests/jinja_context_tests.py @@ -22,7 +22,7 @@ from tests.base_tests import SupersetTestCase -class Jinja2ContextTests(SupersetTestCase): +class TestJinja2Context(SupersetTestCase): def test_filter_values_default(self) -> None: with app.test_request_context(): self.assertEquals(filter_values("name", "foo"), ["foo"]) diff --git a/tests/load_examples_test.py b/tests/load_examples_test.py index 5b61730163d32..7fe94e98d0081 100644 --- a/tests/load_examples_test.py +++ b/tests/load_examples_test.py @@ -17,11 +17,7 @@ from .base_tests import SupersetTestCase -class SupersetDataFrameTestCase(SupersetTestCase): - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - self.examples = None - +class TestSupersetDataFrame(SupersetTestCase): def setUp(self) -> None: # Late importing here as we need an app context to be pushed... from superset import examples diff --git a/tests/log_api_tests.py b/tests/log_api_tests.py index dbf1084c1fd57..f13d5c9e522d1 100644 --- a/tests/log_api_tests.py +++ b/tests/log_api_tests.py @@ -29,7 +29,7 @@ from .base_tests import SupersetTestCase -class LogApiTests(SupersetTestCase): +class TestLogApi(SupersetTestCase): def insert_log( self, action: str, diff --git a/tests/migration_tests.py b/tests/migration_tests.py index d809da50969dd..444aefbc36253 100644 --- a/tests/migration_tests.py +++ b/tests/migration_tests.py @@ -24,7 +24,7 @@ from .base_tests import SupersetTestCase -class MigrationTestCase(SupersetTestCase): +class TestMigration(SupersetTestCase): def test_upgrade_slice(self): slc = Slice( slice_name="FOO", diff --git a/tests/model_tests.py b/tests/model_tests.py index 4a203a96475d4..c8a1131eca86a 100644 --- a/tests/model_tests.py +++ b/tests/model_tests.py @@ -30,7 +30,7 @@ from .base_tests import SupersetTestCase -class DatabaseModelTestCase(SupersetTestCase): +class TestDatabaseModel(SupersetTestCase): @unittest.skipUnless( SupersetTestCase.is_module_installed("requests"), "requests not installed" ) @@ -173,7 +173,7 @@ def test_multi_statement(self): self.assertEqual(df.iat[0, 0], ";") -class SqlaTableModelTestCase(SupersetTestCase): +class TestSqlaTableModel(SupersetTestCase): def test_get_timestamp_expression(self): tbl = self.get_table_by_name("birth_names") ds_col = tbl.get_column("ds") diff --git a/tests/pandas_postprocessing_tests.py b/tests/pandas_postprocessing_tests.py index 14342cc895dce..839b227170394 100644 --- a/tests/pandas_postprocessing_tests.py +++ b/tests/pandas_postprocessing_tests.py @@ -56,7 +56,7 @@ def round_floats( return [round(val, precision) if val else None for val in floats] -class PostProcessingTestCase(SupersetTestCase): +class TestPostProcessing(SupersetTestCase): def test_pivot(self): aggregates = {"idx_nulls": {"operator": "sum"}} diff --git a/tests/queries/api_tests.py b/tests/queries/api_tests.py index 50168126e16ca..bcd55c9cc246c 100644 --- a/tests/queries/api_tests.py +++ b/tests/queries/api_tests.py @@ -33,7 +33,7 @@ from tests.base_tests import SupersetTestCase -class QueryApiTests(SupersetTestCase): +class TestQueryApi(SupersetTestCase): def insert_query( self, database_id: int, diff --git a/tests/query_context_tests.py b/tests/query_context_tests.py index 310df012dca01..eb75820fe48f7 100644 --- a/tests/query_context_tests.py +++ b/tests/query_context_tests.py @@ -28,7 +28,7 @@ from tests.fixtures.query_context import get_query_context -class QueryContextTests(SupersetTestCase): +class TestQueryContext(SupersetTestCase): def test_schema_deserialization(self): """ Ensure that the deserialized QueryContext contains all required fields. diff --git a/tests/result_set_tests.py b/tests/result_set_tests.py index 963cd958197fd..888b695688373 100644 --- a/tests/result_set_tests.py +++ b/tests/result_set_tests.py @@ -25,7 +25,7 @@ from .base_tests import SupersetTestCase -class SupersetResultSetTestCase(SupersetTestCase): +class TestSupersetResultSet(SupersetTestCase): def test_dedup(self): self.assertEqual(dedup(["foo", "bar"]), ["foo", "bar"]) self.assertEqual( diff --git a/tests/schedules_test.py b/tests/schedules_test.py index 348ee862ad30c..a8bd592e74ed4 100644 --- a/tests/schedules_test.py +++ b/tests/schedules_test.py @@ -42,7 +42,7 @@ from .utils import read_fixture -class SchedulesTestCase(SupersetTestCase): +class TestSchedules(SupersetTestCase): RECIPIENTS = "recipient1@superset.com, recipient2@superset.com" BCC = "bcc@superset.com" @@ -379,7 +379,7 @@ def test_deliver_slice_inline_image( { "channels": "#test_channel", "file": element.screenshot_as_png, - "initial_comment": "\n *Participants*\n\n \n ", + "initial_comment": f"\n *Participants*\n\n \n ", "title": "[Report] Participants", }, ) @@ -434,7 +434,7 @@ def test_deliver_slice_attachment( { "channels": "#test_channel", "file": element.screenshot_as_png, - "initial_comment": "\n *Participants*\n\n \n ", + "initial_comment": f"\n *Participants*\n\n \n ", "title": "[Report] Participants", }, ) @@ -481,7 +481,7 @@ def test_deliver_slice_csv_attachment( { "channels": "#test_channel", "file": self.CSV, - "initial_comment": "\n *Participants*\n\n \n ", + "initial_comment": f"\n *Participants*\n\n \n ", "title": "[Report] Participants", }, ) @@ -526,7 +526,7 @@ def test_deliver_slice_csv_inline( { "channels": "#test_channel", "file": self.CSV, - "initial_comment": "\n *Participants*\n\n \n ", + "initial_comment": f"\n *Participants*\n\n \n ", "title": "[Report] Participants", }, ) diff --git a/tests/security/analytics_db_safety_tests.py b/tests/security/analytics_db_safety_tests.py index 5d32646e6d4a0..942320865b314 100644 --- a/tests/security/analytics_db_safety_tests.py +++ b/tests/security/analytics_db_safety_tests.py @@ -22,7 +22,7 @@ from tests.base_tests import SupersetTestCase -class DBConnectionsTest(SupersetTestCase): +class TestDBConnections(SupersetTestCase): def test_check_sqlalchemy_uri_ok(self): check_sqlalchemy_uri("postgres://user:password@test.com") diff --git a/tests/security_tests.py b/tests/security_tests.py index b4279827cd5a2..7568cd6111105 100644 --- a/tests/security_tests.py +++ b/tests/security_tests.py @@ -65,7 +65,7 @@ def delete_schema_perm(view_menu_name: str) -> None: return None -class RolePermissionTests(SupersetTestCase): +class TestRolePermission(SupersetTestCase): """Testing export role permissions.""" def setUp(self): @@ -818,7 +818,7 @@ def test_views_are_secured(self): raise Exception(f"Some views are not secured:\n{view_str}") -class SecurityManagerTests(SupersetTestCase): +class TestSecurityManager(SupersetTestCase): """ Testing the Security Manager. """ @@ -930,7 +930,7 @@ def test_raise_for_access_viz(self, mock_can_access_schema, mock_can_access): security_manager.raise_for_access(viz=test_viz) -class RowLevelSecurityTests(SupersetTestCase): +class TestRowLevelSecurity(SupersetTestCase): """ Testing Row Level Security """ diff --git a/tests/sql_parse_tests.py b/tests/sql_parse_tests.py index e09f4f10b675e..5d2fc4def24fc 100644 --- a/tests/sql_parse_tests.py +++ b/tests/sql_parse_tests.py @@ -19,7 +19,7 @@ from superset.sql_parse import ParsedQuery, Table -class SupersetTestCase(unittest.TestCase): +class TestSupersetSqlParse(unittest.TestCase): def extract_tables(self, query): return ParsedQuery(query).tables diff --git a/tests/sql_validator_tests.py b/tests/sql_validator_tests.py index 4cf2956bae748..4f47233118abd 100644 --- a/tests/sql_validator_tests.py +++ b/tests/sql_validator_tests.py @@ -42,7 +42,7 @@ } -class SqlValidatorEndpointTests(SupersetTestCase): +class TestSqlValidatorEndpoint(SupersetTestCase): """Testing for Sql Lab querytext validation endpoint""" def tearDown(self): @@ -114,7 +114,7 @@ def test_validate_sql_endpoint_failure(self, get_validator_by_name): self.assertIn("Kaboom!", resp["error"]) -class BaseValidatorTests(SupersetTestCase): +class TestBaseValidator(SupersetTestCase): """Testing for the base sql validator""" def setUp(self): @@ -125,7 +125,7 @@ def test_validator_excepts(self): self.validator.validate(None, None, None) -class PrestoValidatorTests(SupersetTestCase): +class TestPrestoValidator(SupersetTestCase): """Testing for the prestodb sql validator""" def setUp(self): diff --git a/tests/sqla_models_tests.py b/tests/sqla_models_tests.py index aa2daf9148e05..4222cdb3a2c2a 100644 --- a/tests/sqla_models_tests.py +++ b/tests/sqla_models_tests.py @@ -27,7 +27,7 @@ from .base_tests import SupersetTestCase -class DatabaseModelTestCase(SupersetTestCase): +class TestDatabaseModel(SupersetTestCase): def test_is_time_druid_time_col(self): """Druid has a special __time column""" diff --git a/tests/sqllab_tests.py b/tests/sqllab_tests.py index 426649a13a74d..a43a4b16f1f22 100644 --- a/tests/sqllab_tests.py +++ b/tests/sqllab_tests.py @@ -40,12 +40,9 @@ QUERY_3 = "SELECT * FROM birth_names LIMIT 10" -class SqlLabTests(SupersetTestCase): +class TestSqlLab(SupersetTestCase): """Testings for Sql Lab""" - def __init__(self, *args, **kwargs): - super(SqlLabTests, self).__init__(*args, **kwargs) - def run_some_queries(self): db.session.query(Query).delete() db.session.commit() diff --git a/tests/stats_logger_tests.py b/tests/stats_logger_tests.py index f76befb8f1ec5..e18f60da8e9b7 100644 --- a/tests/stats_logger_tests.py +++ b/tests/stats_logger_tests.py @@ -21,7 +21,7 @@ from superset.stats_logger import StatsdStatsLogger -class StatsdStatsLoggerTest(TestCase): +class TestStatsdStatsLogger(TestCase): def verify_client_calls(self, logger, client): logger.incr("foo1") client.incr.assert_called_once() diff --git a/tests/strategy_tests.py b/tests/strategy_tests.py index 08d25b2e2fe7e..c4f0019c6dd9c 100644 --- a/tests/strategy_tests.py +++ b/tests/strategy_tests.py @@ -50,10 +50,7 @@ } -class CacheWarmUpTests(SupersetTestCase): - def __init__(self, *args, **kwargs): - super(CacheWarmUpTests, self).__init__(*args, **kwargs) - +class TestCacheWarmUp(SupersetTestCase): def test_get_form_data_chart_only(self): chart_id = 1 result = get_form_data(chart_id, None) diff --git a/tests/tagging_tests.py b/tests/tagging_tests.py index 70785c65ff650..77c80d7e3c991 100644 --- a/tests/tagging_tests.py +++ b/tests/tagging_tests.py @@ -21,7 +21,7 @@ from tests.base_tests import SupersetTestCase -class TaggingTests(SupersetTestCase): +class TestTagging(SupersetTestCase): @skipUnless( (is_feature_enabled("TAGGING_SYSTEM") == False), "skipping as tagging endpoints are not enabled", diff --git a/tests/thumbnails_tests.py b/tests/thumbnails_tests.py index a7803865a1fc9..39f98af4517c4 100644 --- a/tests/thumbnails_tests.py +++ b/tests/thumbnails_tests.py @@ -38,7 +38,7 @@ from .base_tests import SupersetTestCase -class ThumbnailsSeleniumLive(LiveServerTestCase): +class TestThumbnailsSeleniumLive(LiveServerTestCase): def create_app(self): return app @@ -66,7 +66,7 @@ def test_get_async_dashboard_screenshot(self): self.assertEqual(response.getcode(), 202) -class ThumbnailsTests(SupersetTestCase): +class TestThumbnails(SupersetTestCase): mock_image = b"bytes mock image" diff --git a/tests/utils_tests.py b/tests/utils_tests.py index 709d11169507b..28f73c8db59bf 100644 --- a/tests/utils_tests.py +++ b/tests/utils_tests.py @@ -108,7 +108,7 @@ def mock_to_adhoc(filt, expressionType="SIMPLE", clause="where"): return result -class UtilsTestCase(SupersetTestCase): +class TestUtils(SupersetTestCase): def test_json_int_dttm_ser(self): dttm = datetime(2020, 1, 1) ts = 1577836800000.0 diff --git a/tests/viz_tests.py b/tests/viz_tests.py index 0a8a41bb9d474..8290fbf73b21e 100644 --- a/tests/viz_tests.py +++ b/tests/viz_tests.py @@ -37,7 +37,7 @@ logger = logging.getLogger(__name__) -class BaseVizTestCase(SupersetTestCase): +class TestBaseViz(SupersetTestCase): def test_constructor_exception_no_datasource(self): form_data = {} datasource = None @@ -166,7 +166,7 @@ def test_cache_timeout(self): self.assertEqual(app.config["CACHE_DEFAULT_TIMEOUT"], test_viz.cache_timeout) -class TableVizTestCase(SupersetTestCase): +class TestTableViz(SupersetTestCase): def test_get_data_applies_percentage(self): form_data = { "groupby": ["groupA", "groupB"], @@ -443,7 +443,7 @@ def test_adhoc_metric_with_sortby(self): self.assertEqual(["sum_value"], data["columns"]) -class DistBarVizTestCase(SupersetTestCase): +class TestDistBarViz(SupersetTestCase): def test_groupby_nulls(self): form_data = { "metrics": ["votes"], @@ -519,7 +519,7 @@ def test_column_nulls(self): self.assertEqual(expected, data) -class PairedTTestTestCase(SupersetTestCase): +class TestPairedTTest(SupersetTestCase): def test_get_data_transforms_dataframe(self): form_data = { "groupby": ["groupA", "groupB", "groupC"], @@ -659,7 +659,7 @@ def test_get_data_empty_null_keys(self): self.assertEqual(data, expected) -class PartitionVizTestCase(SupersetTestCase): +class TestPartitionViz(SupersetTestCase): @patch("superset.viz.BaseViz.query_obj") def test_query_obj_time_series_option(self, super_query_obj): datasource = self.get_datasource_mock() @@ -863,7 +863,7 @@ def test_get_data_calls_correct_method(self): self.assertEqual(7, len(test_viz.nest_values.mock_calls)) -class RoseVisTestCase(SupersetTestCase): +class TestRoseVis(SupersetTestCase): def test_rose_vis_get_data(self): raw = {} t1 = pd.Timestamp("2000") @@ -899,7 +899,7 @@ def test_rose_vis_get_data(self): self.assertEqual(expected, res) -class TimeSeriesTableVizTestCase(SupersetTestCase): +class TestTimeSeriesTableViz(SupersetTestCase): def test_get_data_metrics(self): form_data = {"metrics": ["sum__A", "count"], "groupby": []} datasource = self.get_datasource_mock() @@ -956,7 +956,7 @@ def test_query_obj_throws_metrics_and_groupby(self, super_query_obj): test_viz.query_obj() -class BaseDeckGLVizTestCase(SupersetTestCase): +class TestBaseDeckGLViz(SupersetTestCase): def test_get_metrics(self): form_data = load_fixture("deck_path_form_data.json") datasource = self.get_datasource_mock() @@ -1133,7 +1133,7 @@ def test_filter_nulls(self, mock_uuid4): assert expected_results.get(mock_key) == adhoc_filters -class TimeSeriesVizTestCase(SupersetTestCase): +class TestTimeSeriesViz(SupersetTestCase): def test_timeseries_unicode_data(self): datasource = self.get_datasource_mock() form_data = {"groupby": ["name"], "metrics": ["sum__payout"]} @@ -1258,7 +1258,7 @@ def test_apply_rolling(self): ) -class BigNumberVizTestCase(SupersetTestCase): +class TestBigNumberViz(SupersetTestCase): def test_get_data(self): datasource = self.get_datasource_mock() df = pd.DataFrame( diff --git a/tox.ini b/tox.ini index 94c86e2008909..9ff47a24fa169 100644 --- a/tox.ini +++ b/tox.ini @@ -18,8 +18,10 @@ commands = {toxinidir}/superset/bin/superset db upgrade {toxinidir}/superset/bin/superset init - nosetests tests/load_examples_test.py - nosetests --exclude=load_examples_test {posargs:tests} + pytest -ra -q tests/load_examples_test.py + # use -s to be able to use break pointers. + # no args or tests/* can be passed as an argument to run all tests + pytest --ignore=load_examples_test {posargs} deps = -rrequirements.txt -rrequirements-dev.txt