diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2022-11-17 14:35:10 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@ci3.zzzcomputing.com> | 2022-11-17 14:35:10 +0000 |
| commit | 60cc662861232ac40bcfd0461b1b1845b643464a (patch) | |
| tree | 97b8ca4a8e98aa1210bccc6051c60df13585d7c5 /test/dialect/postgresql | |
| parent | 200e70b9745f1f344be4a35bb8f2b5f01b40d467 (diff) | |
| parent | 4eb4ceca36c7ce931ea65ac06d6ed08bf459fc66 (diff) | |
| download | sqlalchemy-60cc662861232ac40bcfd0461b1b1845b643464a.tar.gz | |
Merge "Try running pyupgrade on the code" into main
Diffstat (limited to 'test/dialect/postgresql')
| -rw-r--r-- | test/dialect/postgresql/test_compiler.py | 5 | ||||
| -rw-r--r-- | test/dialect/postgresql/test_dialect.py | 1 | ||||
| -rw-r--r-- | test/dialect/postgresql/test_on_conflict.py | 2 | ||||
| -rw-r--r-- | test/dialect/postgresql/test_query.py | 2 | ||||
| -rw-r--r-- | test/dialect/postgresql/test_reflection.py | 60 | ||||
| -rw-r--r-- | test/dialect/postgresql/test_types.py | 15 |
6 files changed, 37 insertions, 48 deletions
diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py index 338d0da4e..431cd7ded 100644 --- a/test/dialect/postgresql/test_compiler.py +++ b/test/dialect/postgresql/test_compiler.py @@ -1,4 +1,3 @@ -# coding: utf-8 from sqlalchemy import and_ from sqlalchemy import BigInteger from sqlalchemy import bindparam @@ -2871,7 +2870,7 @@ class InsertOnConflictTest(fixtures.TablesTest, AssertsCompiledSQL): i = i.on_conflict_do_update( constraint=self.excl_constr_anon, set_=dict(name=i.excluded.name), - where=((self.table1.c.name != i.excluded.name)), + where=(self.table1.c.name != i.excluded.name), ) self.assert_compile( i, @@ -2913,7 +2912,7 @@ class InsertOnConflictTest(fixtures.TablesTest, AssertsCompiledSQL): i.on_conflict_do_update( constraint=self.excl_constr_anon, set_=dict(name=i.excluded.name), - where=((self.table1.c.name != i.excluded.name)), + where=(self.table1.c.name != i.excluded.name), ) .returning(literal_column("1")) .cte("i_upsert") diff --git a/test/dialect/postgresql/test_dialect.py b/test/dialect/postgresql/test_dialect.py index 27d4a4cf9..e8d9a8eb6 100644 --- a/test/dialect/postgresql/test_dialect.py +++ b/test/dialect/postgresql/test_dialect.py @@ -1,4 +1,3 @@ -# coding: utf-8 import dataclasses import datetime import logging diff --git a/test/dialect/postgresql/test_on_conflict.py b/test/dialect/postgresql/test_on_conflict.py index 9c1aaf78e..3cdad78f0 100644 --- a/test/dialect/postgresql/test_on_conflict.py +++ b/test/dialect/postgresql/test_on_conflict.py @@ -1,5 +1,3 @@ -# coding: utf-8 - from sqlalchemy import Column from sqlalchemy import exc from sqlalchemy import Integer diff --git a/test/dialect/postgresql/test_query.py b/test/dialect/postgresql/test_query.py index 6afc2f7c1..42ec20743 100644 --- a/test/dialect/postgresql/test_query.py +++ b/test/dialect/postgresql/test_query.py @@ -1,5 +1,3 @@ -# coding: utf-8 - import datetime from sqlalchemy import and_ 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, diff --git a/test/dialect/postgresql/test_types.py b/test/dialect/postgresql/test_types.py index 39e7d7317..61de57ed4 100644 --- a/test/dialect/postgresql/test_types.py +++ b/test/dialect/postgresql/test_types.py @@ -1,4 +1,3 @@ -# coding: utf-8 import datetime import decimal from enum import Enum as _PY_Enum @@ -2235,8 +2234,8 @@ class ArrayRoundTripTest: ) # hashable eq_( - set(row[1] for row in r), - set([("1", "2", "3"), ("4", "5", "6"), (("4", "5"), ("6", "7"))]), + {row[1] for row in r}, + {("1", "2", "3"), ("4", "5", "6"), (("4", "5"), ("6", "7"))}, ) def test_array_plus_native_enum_create(self, metadata, connection): @@ -2261,8 +2260,8 @@ class ArrayRoundTripTest: t.create(connection) eq_( - set(e["name"] for e in inspect(connection).get_enums()), - set(["my_enum_1", "my_enum_2", "my_enum_3"]), + {e["name"] for e in inspect(connection).get_enums()}, + {"my_enum_1", "my_enum_2", "my_enum_3"}, ) t.drop(connection) eq_(inspect(connection).get_enums(), []) @@ -2686,7 +2685,7 @@ class _ArrayOfEnum(TypeDecorator): return sa.cast(bindvalue, self) def result_processor(self, dialect, coltype): - super_rp = super(_ArrayOfEnum, self).result_processor(dialect, coltype) + super_rp = super().result_processor(dialect, coltype) def handle_raw_string(value): inner = re.match(r"^{(.*)}$", value).group(1) @@ -5253,7 +5252,7 @@ class JSONBTest(JSONTest): ), ) def test_where(self, whereclause_fn, expected): - super(JSONBTest, self).test_where(whereclause_fn, expected) + super().test_where(whereclause_fn, expected) class JSONBRoundTripTest(JSONRoundTripTest): @@ -5263,7 +5262,7 @@ class JSONBRoundTripTest(JSONRoundTripTest): @testing.requires.postgresql_utf8_server_encoding def test_unicode_round_trip(self, connection): - super(JSONBRoundTripTest, self).test_unicode_round_trip(connection) + super().test_unicode_round_trip(connection) @testing.only_on("postgresql >= 12") def test_cast_jsonpath(self, connection): |
