mirror of
https://github.com/apache/superset.git
synced 2026-04-12 04:37:49 +00:00
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 <bogdankyryliuk@dropbox.com>
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
@@ -23,12 +23,12 @@ from superset.db_engine_specs import engines
|
||||
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"
|
||||
|
||||
@@ -23,7 +23,7 @@ from tests.base_tests import SupersetTestCase
|
||||
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
|
||||
):
|
||||
|
||||
@@ -22,10 +22,10 @@ from sqlalchemy import column
|
||||
|
||||
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
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -19,10 +19,10 @@ from unittest import mock
|
||||
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: <PERFLOG method=compile from=org.apache.hadoop.hive.ql.Driver>
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -24,10 +24,10 @@ from sqlalchemy.types import String, UnicodeText
|
||||
|
||||
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)
|
||||
|
||||
@@ -20,12 +20,12 @@ from sqlalchemy.dialects import mysql
|
||||
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"""
|
||||
|
||||
@@ -19,10 +19,10 @@ from sqlalchemy.dialects import oracle
|
||||
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)
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -20,10 +20,10 @@ from sqlalchemy import column, literal_column
|
||||
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
|
||||
|
||||
@@ -21,13 +21,11 @@ from sqlalchemy.engine.result import RowProxy
|
||||
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"))
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@ import json
|
||||
|
||||
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()
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user