summaryrefslogtreecommitdiff
path: root/test/dialect/postgresql/test_reflection.py
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2022-11-17 14:35:10 +0000
committerGerrit Code Review <gerrit@ci3.zzzcomputing.com>2022-11-17 14:35:10 +0000
commit60cc662861232ac40bcfd0461b1b1845b643464a (patch)
tree97b8ca4a8e98aa1210bccc6051c60df13585d7c5 /test/dialect/postgresql/test_reflection.py
parent200e70b9745f1f344be4a35bb8f2b5f01b40d467 (diff)
parent4eb4ceca36c7ce931ea65ac06d6ed08bf459fc66 (diff)
downloadsqlalchemy-60cc662861232ac40bcfd0461b1b1845b643464a.tar.gz
Merge "Try running pyupgrade on the code" into main
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 481924c38..4fb1f8e70 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
@@ -122,7 +120,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",
)
@@ -288,7 +286,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",
)
@@ -299,24 +297,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):
@@ -483,7 +481,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)
@@ -534,7 +532,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)
@@ -1083,7 +1081,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()
@@ -1095,12 +1093,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(
@@ -1127,7 +1123,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):
@@ -1883,10 +1879,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)
@@ -1894,8 +1890,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)
@@ -1953,10 +1949,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"]
@@ -1964,8 +1960,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
@@ -2007,11 +2003,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,