summaryrefslogtreecommitdiff
path: root/test/dialect/postgresql/test_reflection.py
diff options
context:
space:
mode:
authorFederico Caselli <cfederico87@gmail.com>2022-11-03 20:52:21 +0100
committerFederico Caselli <cfederico87@gmail.com>2022-11-16 23:03:04 +0100
commit4eb4ceca36c7ce931ea65ac06d6ed08bf459fc66 (patch)
tree4970cff3f78489a4a0066cd27fd4bae682402957 /test/dialect/postgresql/test_reflection.py
parent3fc6c40ea77c971d3067dab0fdf57a5b5313b69b (diff)
downloadsqlalchemy-4eb4ceca36c7ce931ea65ac06d6ed08bf459fc66.tar.gz
Try running pyupgrade on the code
command run is "pyupgrade --py37-plus --keep-runtime-typing --keep-percent-format <files...>" pyupgrade will change assert_ to assertTrue. That was reverted since assertTrue does not exists in sqlalchemy fixtures Change-Id: Ie1ed2675c7b11d893d78e028aad0d1576baebb55
Diffstat (limited to 'test/dialect/postgresql/test_reflection.py')
-rw-r--r--test/dialect/postgresql/test_reflection.py60
1 files changed, 28 insertions, 32 deletions
diff --git a/test/dialect/postgresql/test_reflection.py b/test/dialect/postgresql/test_reflection.py
index f0893d822..88b0b73cc 100644
--- a/test/dialect/postgresql/test_reflection.py
+++ b/test/dialect/postgresql/test_reflection.py
@@ -1,5 +1,3 @@
-# coding: utf-8
-
import itertools
from operator import itemgetter
import re
@@ -120,7 +118,7 @@ class ForeignTableReflectionTest(
table = Table("test_foreigntable", metadata, autoload_with=connection)
eq_(
set(table.columns.keys()),
- set(["id", "data"]),
+ {"id", "data"},
"Columns of reflected foreign table didn't equal expected columns",
)
@@ -286,7 +284,7 @@ class MaterializedViewReflectionTest(
table = Table("test_mview", metadata, autoload_with=connection)
eq_(
set(table.columns.keys()),
- set(["id", "data"]),
+ {"id", "data"},
"Columns of reflected mview didn't equal expected columns",
)
@@ -297,24 +295,24 @@ class MaterializedViewReflectionTest(
def test_get_view_names(self, inspect_fixture):
insp, conn = inspect_fixture
- eq_(set(insp.get_view_names()), set(["test_regview"]))
+ eq_(set(insp.get_view_names()), {"test_regview"})
def test_get_materialized_view_names(self, inspect_fixture):
insp, conn = inspect_fixture
- eq_(set(insp.get_materialized_view_names()), set(["test_mview"]))
+ eq_(set(insp.get_materialized_view_names()), {"test_mview"})
def test_get_view_names_reflection_cache_ok(self, connection):
insp = inspect(connection)
- eq_(set(insp.get_view_names()), set(["test_regview"]))
+ eq_(set(insp.get_view_names()), {"test_regview"})
eq_(
set(insp.get_materialized_view_names()),
- set(["test_mview"]),
+ {"test_mview"},
)
eq_(
set(insp.get_view_names()).union(
insp.get_materialized_view_names()
),
- set(["test_regview", "test_mview"]),
+ {"test_regview", "test_mview"},
)
def test_get_view_definition(self, connection):
@@ -481,7 +479,7 @@ class DomainReflectionTest(fixtures.TestBase, AssertsExecutionResults):
table = Table("testtable", metadata, autoload_with=connection)
eq_(
set(table.columns.keys()),
- set(["question", "answer"]),
+ {"question", "answer"},
"Columns of reflected table didn't equal expected columns",
)
assert isinstance(table.c.answer.type, Integer)
@@ -532,7 +530,7 @@ class DomainReflectionTest(fixtures.TestBase, AssertsExecutionResults):
)
eq_(
set(table.columns.keys()),
- set(["question", "answer", "anything"]),
+ {"question", "answer", "anything"},
"Columns of reflected table didn't equal expected columns",
)
assert isinstance(table.c.anything.type, Integer)
@@ -1081,7 +1079,7 @@ class ReflectionTest(
eq_(
set(meta2.tables),
- set(["test_schema_2.some_other_table", "some_table"]),
+ {"test_schema_2.some_other_table", "some_table"},
)
meta3 = MetaData()
@@ -1093,12 +1091,10 @@ class ReflectionTest(
eq_(
set(meta3.tables),
- set(
- [
- "test_schema_2.some_other_table",
- "test_schema.some_table",
- ]
- ),
+ {
+ "test_schema_2.some_other_table",
+ "test_schema.some_table",
+ },
)
def test_cross_schema_reflection_metadata_uses_schema(
@@ -1125,7 +1121,7 @@ class ReflectionTest(
eq_(
set(meta2.tables),
- set(["some_other_table", "test_schema.some_table"]),
+ {"some_other_table", "test_schema.some_table"},
)
def test_uppercase_lowercase_table(self, metadata, connection):
@@ -1881,10 +1877,10 @@ class ReflectionTest(
# PostgreSQL will create an implicit index for a unique
# constraint. Separately we get both
- indexes = set(i["name"] for i in insp.get_indexes("pgsql_uc"))
- constraints = set(
+ indexes = {i["name"] for i in insp.get_indexes("pgsql_uc")}
+ constraints = {
i["name"] for i in insp.get_unique_constraints("pgsql_uc")
- )
+ }
self.assert_("uc_a" in indexes)
self.assert_("uc_a" in constraints)
@@ -1892,8 +1888,8 @@ class ReflectionTest(
# reflection corrects for the dupe
reflected = Table("pgsql_uc", MetaData(), autoload_with=connection)
- indexes = set(i.name for i in reflected.indexes)
- constraints = set(uc.name for uc in reflected.constraints)
+ indexes = {i.name for i in reflected.indexes}
+ constraints = {uc.name for uc in reflected.constraints}
self.assert_("uc_a" not in indexes)
self.assert_("uc_a" in constraints)
@@ -1951,10 +1947,10 @@ class ReflectionTest(
uc_table.create(connection)
- indexes = dict((i["name"], i) for i in insp.get_indexes("pgsql_uc"))
- constraints = set(
+ indexes = {i["name"]: i for i in insp.get_indexes("pgsql_uc")}
+ constraints = {
i["name"] for i in insp.get_unique_constraints("pgsql_uc")
- )
+ }
self.assert_("ix_a" in indexes)
assert indexes["ix_a"]["unique"]
@@ -1962,8 +1958,8 @@ class ReflectionTest(
reflected = Table("pgsql_uc", MetaData(), autoload_with=connection)
- indexes = dict((i.name, i) for i in reflected.indexes)
- constraints = set(uc.name for uc in reflected.constraints)
+ indexes = {i.name: i for i in reflected.indexes}
+ constraints = {uc.name for uc in reflected.constraints}
self.assert_("ix_a" in indexes)
assert indexes["ix_a"].unique
@@ -2005,11 +2001,11 @@ class ReflectionTest(
reflected = Table("pgsql_cc", MetaData(), autoload_with=connection)
- check_constraints = dict(
- (uc.name, uc.sqltext.text)
+ check_constraints = {
+ uc.name: uc.sqltext.text
for uc in reflected.constraints
if isinstance(uc, CheckConstraint)
- )
+ }
eq_(
check_constraints,