chore: enforce more ruff rules (#31447)

Co-authored-by: Elizabeth Thompson <eschutho@gmail.com>
This commit is contained in:
Maxime Beauchemin
2024-12-18 17:41:34 -08:00
committed by GitHub
parent 9da65d6bfd
commit e51b95ffa8
375 changed files with 1821 additions and 1718 deletions

View File

@@ -118,7 +118,7 @@ class TestDatabaseApi(SupersetTestCase):
db.session.commit()
return database
@pytest.fixture()
@pytest.fixture
def create_database_with_report(self):
with self.create_app().app_context():
example_db = get_example_database()
@@ -142,7 +142,7 @@ class TestDatabaseApi(SupersetTestCase):
db.session.delete(database)
db.session.commit()
@pytest.fixture()
@pytest.fixture
def create_database_with_dataset(self):
with self.create_app().app_context():
example_db = get_example_database()
@@ -332,7 +332,7 @@ class TestDatabaseApi(SupersetTestCase):
.filter(SSHTunnel.database_id == response.get("id"))
.one()
)
assert response.get("result")["ssh_tunnel"]["password"] == "XXXXXXXXXX"
assert response.get("result")["ssh_tunnel"]["password"] == "XXXXXXXXXX" # noqa: S105
assert model_ssh_tunnel.database_id == response.get("id")
# Cleanup
model = db.session.query(Database).get(response.get("id"))
@@ -669,7 +669,7 @@ class TestDatabaseApi(SupersetTestCase):
.one()
)
assert model_ssh_tunnel.database_id == response_update.get("id")
assert response_update.get("result")["ssh_tunnel"]["password"] == "XXXXXXXXXX"
assert response_update.get("result")["ssh_tunnel"]["password"] == "XXXXXXXXXX" # noqa: S105
assert model_ssh_tunnel.username == "Test"
assert model_ssh_tunnel.server_address == "123.132.123.1"
assert model_ssh_tunnel.server_port == 8080
@@ -1132,7 +1132,7 @@ class TestDatabaseApi(SupersetTestCase):
example_db = get_example_database()
if example_db.backend in ("sqlite", "hive", "presto"):
return
example_db.password = "wrong_password"
example_db.password = "wrong_password" # noqa: S105
database_data = {
"database_name": "test-create-database-wrong-password",
"sqlalchemy_uri": example_db.sqlalchemy_uri_decrypted,
@@ -1160,7 +1160,7 @@ class TestDatabaseApi(SupersetTestCase):
{
"code": 1015,
"message": (
"Issue 1015 - Issue 1015 - Either the database is spelled incorrectly or does not exist."
"Issue 1015 - Issue 1015 - Either the database is spelled incorrectly or does not exist." # noqa: E501
),
},
],
@@ -1177,7 +1177,7 @@ class TestDatabaseApi(SupersetTestCase):
{
"code": 1013,
"message": (
"Issue 1013 - The password provided when connecting to a database is not valid."
"Issue 1013 - The password provided when connecting to a database is not valid." # noqa: E501
),
}
],
@@ -1225,7 +1225,7 @@ class TestDatabaseApi(SupersetTestCase):
test_database = self.insert_database(
"test-database1", example_db.sqlalchemy_uri_decrypted
)
example_db.password = "wrong_password"
example_db.password = "wrong_password" # noqa: S105
database_data = {
"sqlalchemy_uri": example_db.sqlalchemy_uri_decrypted,
}
@@ -1771,7 +1771,7 @@ class TestDatabaseApi(SupersetTestCase):
db.session.delete(database)
db.session.commit()
def mock_csv_function(d, user):
def mock_csv_function(d, user): # noqa: N805
return d.get_all_schema_names()
@mock.patch(
@@ -1818,7 +1818,7 @@ class TestDatabaseApi(SupersetTestCase):
db.session.delete(database)
db.session.commit()
def mock_empty_csv_function(d, user):
def mock_empty_csv_function(d, user): # noqa: N805
return []
@mock.patch(
@@ -1979,7 +1979,7 @@ class TestDatabaseApi(SupersetTestCase):
schema_name = self.default_schema_backend_map[database.backend]
rv = self.client.get(
f"api/v1/database/{database.id}/tables/?q={prison.dumps({'schema_name': schema_name})}"
f"api/v1/database/{database.id}/tables/?q={prison.dumps({'schema_name': schema_name})}" # noqa: E501
)
assert rv.status_code == 200
@@ -2001,7 +2001,7 @@ class TestDatabaseApi(SupersetTestCase):
"""
self.login(GAMMA_USERNAME)
example_db = get_example_database()
uri = f"api/v1/database/{example_db.id}/tables/?q={prison.dumps({'schema_name': 'non_existent'})}"
uri = f"api/v1/database/{example_db.id}/tables/?q={prison.dumps({'schema_name': 'non_existent'})}" # noqa: E501
rv = self.client.get(uri)
assert rv.status_code == 404
logger_mock.warning.assert_called_once_with(
@@ -2033,7 +2033,7 @@ class TestDatabaseApi(SupersetTestCase):
mock_can_access_database.side_effect = Exception("Test Error")
rv = self.client.get(
f"api/v1/database/{database.id}/tables/?q={prison.dumps({'schema_name': 'main'})}"
f"api/v1/database/{database.id}/tables/?q={prison.dumps({'schema_name': 'main'})}" # noqa: E501
)
assert rv.status_code == 422
logger_mock.warning.assert_called_once_with("Test Error", exc_info=True)
@@ -2105,7 +2105,7 @@ class TestDatabaseApi(SupersetTestCase):
"issue_codes": [
{
"code": 1010,
"message": "Issue 1010 - Superset encountered an error while running a command.",
"message": "Issue 1010 - Superset encountered an error while running a command.", # noqa: E501
}
]
},
@@ -2134,7 +2134,7 @@ class TestDatabaseApi(SupersetTestCase):
"issue_codes": [
{
"code": 1010,
"message": "Issue 1010 - Superset encountered an error while running a command.",
"message": "Issue 1010 - Superset encountered an error while running a command.", # noqa: E501
}
]
},
@@ -2163,7 +2163,7 @@ class TestDatabaseApi(SupersetTestCase):
expected_response = {
"message": {
"sqlalchemy_uri": [
"SQLiteDialect_pysqlite cannot be used as a data source for security reasons."
"SQLiteDialect_pysqlite cannot be used as a data source for security reasons." # noqa: E501
]
}
}
@@ -2183,7 +2183,7 @@ class TestDatabaseApi(SupersetTestCase):
"""
Database API: Test test connection failed due to invalid hostname
"""
msg = 'psql: error: could not translate host name "localhost_" to address: nodename nor servname provided, or not known'
msg = 'psql: error: could not translate host name "localhost_" to address: nodename nor servname provided, or not known' # noqa: E501
mock_build_db.return_value.set_sqlalchemy_uri.side_effect = DBAPIError(
msg, None, None
)
@@ -2361,27 +2361,30 @@ class TestDatabaseApi(SupersetTestCase):
response = json.loads(rv.data.decode("utf-8"))
assert rv.status_code == 422
assert response == {
"errors": [
{
"message": "Error importing database",
"error_type": "GENERIC_COMMAND_ERROR",
"level": "warning",
"extra": {
"databases/imported_database.yaml": "Database already exists and `overwrite=true` was not passed",
"issue_codes": [
{
"code": 1010,
"message": (
"Issue 1010 - Superset encountered an "
"error while running a command."
),
}
],
},
}
]
}
assert (
response
== {
"errors": [
{
"message": "Error importing database",
"error_type": "GENERIC_COMMAND_ERROR",
"level": "warning",
"extra": {
"databases/imported_database.yaml": "Database already exists and `overwrite=true` was not passed", # noqa: E501
"issue_codes": [
{
"code": 1010,
"message": (
"Issue 1010 - Superset encountered an "
"error while running a command."
),
}
],
},
}
]
}
)
# import with overwrite flag
buf = self.create_database_import()
@@ -2555,7 +2558,7 @@ class TestDatabaseApi(SupersetTestCase):
database.sqlalchemy_uri
== "vertica+vertica_python://hackathon:XXXXXXXXXX@host:5433/dbname?ssl=1"
)
assert database.password == "SECRET"
assert database.password == "SECRET" # noqa: S105
db.session.delete(database)
db.session.commit()
@@ -2668,7 +2671,7 @@ class TestDatabaseApi(SupersetTestCase):
.filter(SSHTunnel.database_id == database.id)
.one()
)
assert model_ssh_tunnel.password == "TEST"
assert model_ssh_tunnel.password == "TEST" # noqa: S105
db.session.delete(database)
db.session.commit()
@@ -2709,32 +2712,35 @@ class TestDatabaseApi(SupersetTestCase):
response = json.loads(rv.data.decode("utf-8"))
assert rv.status_code == 422
assert response == {
"errors": [
{
"message": "Error importing database",
"error_type": "GENERIC_COMMAND_ERROR",
"level": "warning",
"extra": {
"databases/imported_database.yaml": {
"_schema": [
"Must provide a private key for the ssh tunnel",
"Must provide a private key password for the ssh tunnel",
]
assert (
response
== {
"errors": [
{
"message": "Error importing database",
"error_type": "GENERIC_COMMAND_ERROR",
"level": "warning",
"extra": {
"databases/imported_database.yaml": {
"_schema": [
"Must provide a private key for the ssh tunnel",
"Must provide a private key password for the ssh tunnel", # noqa: E501
]
},
"issue_codes": [
{
"code": 1010,
"message": (
"Issue 1010 - Superset encountered an "
"error while running a command."
),
}
],
},
"issue_codes": [
{
"code": 1010,
"message": (
"Issue 1010 - Superset encountered an "
"error while running a command."
),
}
],
},
}
]
}
}
]
}
)
@mock.patch("superset.databases.schemas.is_feature_enabled")
@mock.patch("superset.commands.database.importers.v1.utils.add_permissions")
@@ -2787,7 +2793,7 @@ class TestDatabaseApi(SupersetTestCase):
.one()
)
assert model_ssh_tunnel.private_key == "TestPrivateKey"
assert model_ssh_tunnel.private_key_password == "TEST"
assert model_ssh_tunnel.private_key_password == "TEST" # noqa: S105
db.session.delete(database)
db.session.commit()
@@ -3001,32 +3007,35 @@ class TestDatabaseApi(SupersetTestCase):
response = json.loads(rv.data.decode("utf-8"))
assert rv.status_code == 422
assert response == {
"errors": [
{
"message": "Error importing database",
"error_type": "GENERIC_COMMAND_ERROR",
"level": "warning",
"extra": {
"databases/imported_database.yaml": {
"_schema": [
"Must provide a private key for the ssh tunnel",
"Must provide a private key password for the ssh tunnel",
]
assert (
response
== {
"errors": [
{
"message": "Error importing database",
"error_type": "GENERIC_COMMAND_ERROR",
"level": "warning",
"extra": {
"databases/imported_database.yaml": {
"_schema": [
"Must provide a private key for the ssh tunnel",
"Must provide a private key password for the ssh tunnel", # noqa: E501
]
},
"issue_codes": [
{
"code": 1010,
"message": (
"Issue 1010 - Superset encountered an "
"error while running a command."
),
}
],
},
"issue_codes": [
{
"code": 1010,
"message": (
"Issue 1010 - Superset encountered an "
"error while running a command."
),
}
],
},
}
]
}
}
]
}
)
@mock.patch(
"superset.db_engine_specs.base.BaseEngineSpec.get_function_names",
@@ -3210,7 +3219,7 @@ class TestDatabaseApi(SupersetTestCase):
"type": "string",
},
"encryption": {
"description": "Use an encrypted connection to the database",
"description": "Use an encrypted connection to the database", # noqa: E501
"type": "boolean",
},
"host": {
@@ -3234,7 +3243,7 @@ class TestDatabaseApi(SupersetTestCase):
"type": "object",
},
"ssh": {
"description": "Use an ssh tunnel connection to the database",
"description": "Use an ssh tunnel connection to the database", # noqa: E501
"type": "boolean",
},
"username": {
@@ -3294,7 +3303,7 @@ class TestDatabaseApi(SupersetTestCase):
"type": "string",
},
"encryption": {
"description": "Use an encrypted connection to the database",
"description": "Use an encrypted connection to the database", # noqa: E501
"type": "boolean",
},
"host": {
@@ -3318,7 +3327,7 @@ class TestDatabaseApi(SupersetTestCase):
"type": "object",
},
"ssh": {
"description": "Use an ssh tunnel connection to the database",
"description": "Use an ssh tunnel connection to the database", # noqa: E501
"type": "boolean",
},
"username": {
@@ -3378,7 +3387,7 @@ class TestDatabaseApi(SupersetTestCase):
"type": "string",
},
"encryption": {
"description": "Use an encrypted connection to the database",
"description": "Use an encrypted connection to the database", # noqa: E501
"type": "boolean",
},
"host": {
@@ -3402,7 +3411,7 @@ class TestDatabaseApi(SupersetTestCase):
"type": "object",
},
"ssh": {
"description": "Use an ssh tunnel connection to the database",
"description": "Use an ssh tunnel connection to the database", # noqa: E501
"type": "boolean",
},
"username": {
@@ -3507,7 +3516,7 @@ class TestDatabaseApi(SupersetTestCase):
"issue_codes": [
{
"code": 1019,
"message": "Issue 1019 - The submitted payload has the incorrect format.",
"message": "Issue 1019 - The submitted payload has the incorrect format.", # noqa: E501
}
]
},
@@ -3606,7 +3615,10 @@ class TestDatabaseApi(SupersetTestCase):
@mock.patch("superset.db_engine_specs.base.is_port_open")
@mock.patch("superset.databases.api.ValidateDatabaseParametersCommand")
def test_validate_parameters_valid_payload(
self, ValidateDatabaseParametersCommand, is_port_open, is_hostname_valid
self,
ValidateDatabaseParametersCommand, # noqa: N803
is_port_open,
is_hostname_valid, # noqa: N803
):
is_hostname_valid.return_value = True
is_port_open.return_value = True
@@ -3786,13 +3798,13 @@ class TestDatabaseApi(SupersetTestCase):
"issue_codes": [
{
"code": 1018,
"message": "Issue 1018 - One or more parameters needed to configure a database are missing.",
"message": "Issue 1018 - One or more parameters needed to configure a database are missing.", # noqa: E501
}
],
},
},
{
"message": "The port must be an integer between 0 and 65535 (inclusive).",
"message": "The port must be an integer between 0 and 65535 (inclusive).", # noqa: E501
"error_type": "CONNECTION_INVALID_PORT_ERROR",
"level": "error",
"extra": {

View File

@@ -83,12 +83,12 @@ def get_upload_db():
return db.session.query(Database).filter_by(database_name=CSV_UPLOAD_DATABASE).one()
@pytest.fixture()
@pytest.fixture
def setup_csv_upload_with_context(app_context: AppContext):
yield from _setup_csv_upload()
@pytest.fixture()
@pytest.fixture
def setup_csv_upload_with_context_schema(app_context: AppContext):
yield from _setup_csv_upload(["public"])
@@ -107,7 +107,7 @@ def test_csv_upload_with_nulls():
CSVReader({"null_values": ["N/A", "None"]}),
).run()
with upload_database.get_sqla_engine() as engine:
data = engine.execute(f"SELECT * from {CSV_UPLOAD_TABLE}").fetchall()
data = engine.execute(f"SELECT * from {CSV_UPLOAD_TABLE}").fetchall() # noqa: S608
assert data == [
("name1", None, "city1", "1-1-1980"),
("name2", 29, None, "1-1-1981"),
@@ -151,15 +151,16 @@ def test_csv_upload_with_index():
CSVReader({"dataframe_index": True, "index_label": "id"}),
).run()
with upload_database.get_sqla_engine() as engine:
data = engine.execute(f"SELECT * from {CSV_UPLOAD_TABLE}").fetchall()
data = engine.execute(f"SELECT * from {CSV_UPLOAD_TABLE}").fetchall() # noqa: S608
assert data == [
(0, "name1", 30, "city1", "1-1-1980"),
(1, "name2", 29, "city2", "1-1-1981"),
(2, "name3", 28, "city3", "1-1-1982"),
]
# assert column names
assert [
col for col in engine.execute(f"SELECT * from {CSV_UPLOAD_TABLE}").keys()
assert [ # noqa: C416
col
for col in engine.execute(f"SELECT * from {CSV_UPLOAD_TABLE}").keys() # noqa: S608
] == [
"id",
"Name",

View File

@@ -338,7 +338,7 @@ class TestExportDatabasesCommand(SupersetTestCase):
example_db = get_example_database()
command = ExportDatabasesCommand([example_db.id])
contents = command.run()
with self.assertRaises(DatabaseNotFoundError):
with self.assertRaises(DatabaseNotFoundError): # noqa: PT027
next(contents)
@patch("superset.security.manager.g")
@@ -347,7 +347,7 @@ class TestExportDatabasesCommand(SupersetTestCase):
mock_g.user = security_manager.find_user("admin")
command = ExportDatabasesCommand([-1])
contents = command.run()
with self.assertRaises(DatabaseNotFoundError):
with self.assertRaises(DatabaseNotFoundError): # noqa: PT027
next(contents)
@patch("superset.security.manager.g")
@@ -680,7 +680,7 @@ class TestImportDatabasesCommand(SupersetTestCase):
mock_add_permissions,
mock_schema_is_feature_enabled,
):
"""Test that database imports with masked ssh_tunnel private_key and private_key_password are rejected"""
"""Test that database imports with masked ssh_tunnel private_key and private_key_password are rejected""" # noqa: E501
mock_schema_is_feature_enabled.return_value = True
masked_database_config = database_with_ssh_tunnel_config_private_key.copy()
contents = {
@@ -713,7 +713,7 @@ class TestImportDatabasesCommand(SupersetTestCase):
mock_g.user = security_manager.find_user("admin")
mock_schema_is_feature_enabled.return_value = True
masked_database_config = database_with_ssh_tunnel_config_password.copy()
masked_database_config["ssh_tunnel"]["password"] = "TEST"
masked_database_config["ssh_tunnel"]["password"] = "TEST" # noqa: S105
contents = {
"metadata.yaml": yaml.safe_dump(database_metadata_config),
"databases/imported_database.yaml": yaml.safe_dump(masked_database_config),
@@ -740,7 +740,7 @@ class TestImportDatabasesCommand(SupersetTestCase):
.filter(SSHTunnel.database_id == database.id)
.one()
)
assert model_ssh_tunnel.password == "TEST"
assert model_ssh_tunnel.password == "TEST" # noqa: S105
db.session.delete(database)
db.session.commit()
@@ -754,13 +754,13 @@ class TestImportDatabasesCommand(SupersetTestCase):
mock_g,
mock_schema_is_feature_enabled,
):
"""Test that a database with ssh_tunnel private_key and private_key_password can be imported"""
"""Test that a database with ssh_tunnel private_key and private_key_password can be imported""" # noqa: E501
mock_g.user = security_manager.find_user("admin")
mock_schema_is_feature_enabled.return_value = True
masked_database_config = database_with_ssh_tunnel_config_private_key.copy()
masked_database_config["ssh_tunnel"]["private_key"] = "TestPrivateKey"
masked_database_config["ssh_tunnel"]["private_key_password"] = "TEST"
masked_database_config["ssh_tunnel"]["private_key_password"] = "TEST" # noqa: S105
contents = {
"metadata.yaml": yaml.safe_dump(database_metadata_config),
"databases/imported_database.yaml": yaml.safe_dump(masked_database_config),
@@ -788,7 +788,7 @@ class TestImportDatabasesCommand(SupersetTestCase):
.one()
)
assert model_ssh_tunnel.private_key == "TestPrivateKey"
assert model_ssh_tunnel.private_key_password == "TEST"
assert model_ssh_tunnel.private_key_password == "TEST" # noqa: S105
db.session.delete(database)
db.session.commit()
@@ -819,7 +819,7 @@ class TestImportDatabasesCommand(SupersetTestCase):
mock_add_permissions,
mock_schema_is_feature_enabled,
):
"""Test that databases with ssh_tunnels that have multiple credentials are rejected"""
"""Test that databases with ssh_tunnels that have multiple credentials are rejected""" # noqa: E501
mock_schema_is_feature_enabled.return_value = True
masked_database_config = database_with_ssh_tunnel_config_mix_credentials.copy()
contents = {
@@ -840,7 +840,7 @@ class TestImportDatabasesCommand(SupersetTestCase):
mock_add_permissions,
mock_schema_is_feature_enabled,
):
"""Test that databases with ssh_tunnels that have multiple credentials are rejected"""
"""Test that databases with ssh_tunnels that have multiple credentials are rejected""" # noqa: E501
mock_schema_is_feature_enabled.return_value = True
masked_database_config = (
database_with_ssh_tunnel_config_private_pass_only.copy()
@@ -878,7 +878,7 @@ class TestImportDatabasesCommand(SupersetTestCase):
"metadata.yaml": yaml.safe_dump(database_metadata_config),
}
command = ImportDatabasesCommand(contents)
with pytest.raises(Exception) as excinfo:
with pytest.raises(Exception) as excinfo: # noqa: PT011
command.run()
assert str(excinfo.value) == "Import database failed for an unknown reason"
@@ -902,7 +902,7 @@ class TestTestConnectionDatabaseCommand(SupersetTestCase):
json_payload = {"sqlalchemy_uri": db_uri}
command_without_db_name = TestConnectionDatabaseCommand(json_payload)
with pytest.raises(DatabaseTestConnectionUnexpectedError) as excinfo:
with pytest.raises(DatabaseTestConnectionUnexpectedError) as excinfo: # noqa: PT012
command_without_db_name.run()
assert str(excinfo.value) == (
"Unexpected error occurred, please check your logs for details"
@@ -971,7 +971,7 @@ class TestTestConnectionDatabaseCommand(SupersetTestCase):
json_payload = {"sqlalchemy_uri": db_uri}
command_without_db_name = TestConnectionDatabaseCommand(json_payload)
with pytest.raises(DatabaseSecurityUnsafeError) as excinfo:
with pytest.raises(DatabaseSecurityUnsafeError) as excinfo: # noqa: PT012
command_without_db_name.run()
assert str(excinfo.value) == ("Stopped an unsafe database connection")
@@ -993,7 +993,7 @@ class TestTestConnectionDatabaseCommand(SupersetTestCase):
json_payload = {"sqlalchemy_uri": db_uri}
command_without_db_name = TestConnectionDatabaseCommand(json_payload)
with pytest.raises(SupersetErrorsException) as excinfo:
with pytest.raises(SupersetErrorsException) as excinfo: # noqa: PT012
command_without_db_name.run()
assert str(excinfo.value) == (
"Connection failed, please check your connection settings"
@@ -1005,7 +1005,7 @@ class TestTestConnectionDatabaseCommand(SupersetTestCase):
@patch("superset.db_engine_specs.base.is_hostname_valid")
@patch("superset.db_engine_specs.base.is_port_open")
@patch("superset.commands.database.validate.DatabaseDAO")
def test_validate(DatabaseDAO, is_port_open, is_hostname_valid, app_context):
def test_validate(DatabaseDAO, is_port_open, is_hostname_valid, app_context): # noqa: N803
"""
Test parameter validation.
"""
@@ -1060,7 +1060,7 @@ def test_validate_partial(is_port_open, is_hostname_valid, app_context):
"issue_codes": [
{
"code": 1018,
"message": "Issue 1018 - One or more parameters needed to configure a database are missing.",
"message": "Issue 1018 - One or more parameters needed to configure a database are missing.", # noqa: E501
}
],
},
@@ -1099,7 +1099,7 @@ def test_validate_partial_invalid_hostname(is_hostname_valid, app_context):
"issue_codes": [
{
"code": 1018,
"message": "Issue 1018 - One or more parameters needed to configure a database are missing.",
"message": "Issue 1018 - One or more parameters needed to configure a database are missing.", # noqa: E501
}
],
},
@@ -1113,7 +1113,7 @@ def test_validate_partial_invalid_hostname(is_hostname_valid, app_context):
"issue_codes": [
{
"code": 1007,
"message": "Issue 1007 - The hostname provided can't be resolved.",
"message": "Issue 1007 - The hostname provided can't be resolved.", # noqa: E501
}
],
},
@@ -1127,7 +1127,7 @@ class TestTablesDatabaseCommand(SupersetTestCase):
mock_find_by_id.return_value = None
command = TablesDatabaseCommand(1, None, "test", False)
with pytest.raises(DatabaseNotFoundError) as excinfo:
with pytest.raises(DatabaseNotFoundError) as excinfo: # noqa: PT012
command.run()
assert str(excinfo.value) == ("Database not found.")
@@ -1146,7 +1146,7 @@ class TestTablesDatabaseCommand(SupersetTestCase):
mock_g.user = security_manager.find_user("admin")
command = TablesDatabaseCommand(database.id, None, "main", False)
with pytest.raises(SupersetException) as excinfo:
with pytest.raises(SupersetException) as excinfo: # noqa: PT012
command.run()
assert str(excinfo.value) == "Test Error"
@@ -1162,7 +1162,7 @@ class TestTablesDatabaseCommand(SupersetTestCase):
mock_g.user = security_manager.find_user("admin")
command = TablesDatabaseCommand(database.id, None, "main", False)
with pytest.raises(DatabaseTablesUnexpectedError) as excinfo:
with pytest.raises(DatabaseTablesUnexpectedError) as excinfo: # noqa: PT012
command.run()
assert (
str(excinfo.value)