summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2020-09-28 14:08:59 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2020-09-28 15:17:26 -0400
commitc3f102c9fe9811fd5286628cc6aafa5fbc324621 (patch)
tree4a78723089ded623701667de1eee21d22edbe6c1 /lib/sqlalchemy/testing
parent75ac0abc7d5653d10006769a881374a46b706db5 (diff)
downloadsqlalchemy-c3f102c9fe9811fd5286628cc6aafa5fbc324621.tar.gz
upgrade to black 20.8b1
It's better, the majority of these changes look more readable to me. also found some docstrings that had formatting / quoting issues. Change-Id: I582a45fde3a5648b2f36bab96bad56881321899b
Diffstat (limited to 'lib/sqlalchemy/testing')
-rw-r--r--lib/sqlalchemy/testing/assertions.py9
-rw-r--r--lib/sqlalchemy/testing/provision.py7
-rw-r--r--lib/sqlalchemy/testing/requirements.py29
-rw-r--r--lib/sqlalchemy/testing/suite/test_insert.py12
-rw-r--r--lib/sqlalchemy/testing/suite/test_reflection.py36
-rw-r--r--lib/sqlalchemy/testing/suite/test_results.py3
-rw-r--r--lib/sqlalchemy/testing/suite/test_select.py25
-rw-r--r--lib/sqlalchemy/testing/suite/test_sequence.py26
-rw-r--r--lib/sqlalchemy/testing/suite/test_types.py21
-rw-r--r--lib/sqlalchemy/testing/warnings.py4
10 files changed, 117 insertions, 55 deletions
diff --git a/lib/sqlalchemy/testing/assertions.py b/lib/sqlalchemy/testing/assertions.py
index c32b2749b..af168cd85 100644
--- a/lib/sqlalchemy/testing/assertions.py
+++ b/lib/sqlalchemy/testing/assertions.py
@@ -522,9 +522,12 @@ class ComparesTables(object):
assert reflected_table.primary_key.columns[c.name] is not None
def assert_types_base(self, c1, c2):
- assert c1.type._compare_type_affinity(c2.type), (
- "On column %r, type '%s' doesn't correspond to type '%s'"
- % (c1.name, c1.type, c2.type)
+ assert c1.type._compare_type_affinity(
+ c2.type
+ ), "On column %r, type '%s' doesn't correspond to type '%s'" % (
+ c1.name,
+ c1.type,
+ c2.type,
)
diff --git a/lib/sqlalchemy/testing/provision.py b/lib/sqlalchemy/testing/provision.py
index 8bdad357c..18b856fb1 100644
--- a/lib/sqlalchemy/testing/provision.py
+++ b/lib/sqlalchemy/testing/provision.py
@@ -166,7 +166,9 @@ def generate_driver_url(url, driver, query_str):
# type: (URL, str, str) -> URL
backend = url.get_backend_name()
- new_url = url.set(drivername="%s+%s" % (backend, driver),)
+ new_url = url.set(
+ drivername="%s+%s" % (backend, driver),
+ )
new_url = new_url.update_query_string(query_str)
try:
@@ -214,8 +216,7 @@ def drop_db(cfg, eng, ident):
@register.init
def update_db_opts(db_url, db_opts):
- """Set database options (db_opts) for a test database that we created.
- """
+ """Set database options (db_opts) for a test database that we created."""
pass
diff --git a/lib/sqlalchemy/testing/requirements.py b/lib/sqlalchemy/testing/requirements.py
index 97413d32b..b7f0d0f59 100644
--- a/lib/sqlalchemy/testing/requirements.py
+++ b/lib/sqlalchemy/testing/requirements.py
@@ -67,7 +67,7 @@ class SuiteRequirements(Requirements):
@property
def on_update_cascade(self):
- """"target database must support ON UPDATE..CASCADE behavior in
+ """target database must support ON UPDATE..CASCADE behavior in
foreign keys."""
return exclusions.open()
@@ -388,7 +388,7 @@ class SuiteRequirements(Requirements):
@property
def implements_get_lastrowid(self):
- """"target dialect implements the executioncontext.get_lastrowid()
+ """target dialect implements the executioncontext.get_lastrowid()
method without reliance on RETURNING.
"""
@@ -396,7 +396,7 @@ class SuiteRequirements(Requirements):
@property
def emulated_lastrowid(self):
- """"target dialect retrieves cursor.lastrowid, or fetches
+ """target dialect retrieves cursor.lastrowid, or fetches
from a database-side function after an insert() construct executes,
within the get_lastrowid() method.
@@ -408,7 +408,7 @@ class SuiteRequirements(Requirements):
@property
def emulated_lastrowid_even_with_sequences(self):
- """"target dialect retrieves cursor.lastrowid or an equivalent
+ """target dialect retrieves cursor.lastrowid or an equivalent
after an insert() construct executes, even if the table has a
Sequence on it.
@@ -417,7 +417,7 @@ class SuiteRequirements(Requirements):
@property
def dbapi_lastrowid(self):
- """"target platform includes a 'lastrowid' accessor on the DBAPI
+ """target platform includes a 'lastrowid' accessor on the DBAPI
cursor object.
"""
@@ -438,17 +438,16 @@ class SuiteRequirements(Requirements):
@property
def cross_schema_fk_reflection(self):
- """target system must support reflection of inter-schema foreign keys
-
- """
+ """target system must support reflection of inter-schema
+ foreign keys"""
return exclusions.closed()
@property
def implicit_default_schema(self):
"""target system has a strong concept of 'default' schema that can
- be referred to implicitly.
+ be referred to implicitly.
- basically, PostgreSQL.
+ basically, PostgreSQL.
"""
return exclusions.closed()
@@ -535,8 +534,8 @@ class SuiteRequirements(Requirements):
@property
def view_reflection(self):
- """target database must support inspection of the full CREATE VIEW definition.
- """
+ """target database must support inspection of the full CREATE VIEW
+ definition."""
return self.views
@property
@@ -654,9 +653,7 @@ class SuiteRequirements(Requirements):
@property
def symbol_names_w_double_quote(self):
- """Target driver can create tables with a name like 'some " table'
-
- """
+ """Target driver can create tables with a name like 'some " table'"""
return exclusions.open()
@property
@@ -804,7 +801,7 @@ class SuiteRequirements(Requirements):
@property
def json_array_indexes(self):
- """"target platform supports numeric array indexes
+ """target platform supports numeric array indexes
within a JSON structure"""
return self.json_type
diff --git a/lib/sqlalchemy/testing/suite/test_insert.py b/lib/sqlalchemy/testing/suite/test_insert.py
index 7a7eac02f..da59d831f 100644
--- a/lib/sqlalchemy/testing/suite/test_insert.py
+++ b/lib/sqlalchemy/testing/suite/test_insert.py
@@ -42,7 +42,11 @@ class LastrowidTest(fixtures.TablesTest):
def _assert_round_trip(self, table, conn):
row = conn.execute(table.select()).first()
eq_(
- row, (conn.dialect.default_sequence_base, "some data",),
+ row,
+ (
+ conn.dialect.default_sequence_base,
+ "some data",
+ ),
)
def test_autoincrement_on_insert(self, connection):
@@ -289,7 +293,11 @@ class ReturningTest(fixtures.TablesTest):
def _assert_round_trip(self, table, conn):
row = conn.execute(table.select()).first()
eq_(
- row, (conn.dialect.default_sequence_base, "some data",),
+ row,
+ (
+ conn.dialect.default_sequence_base,
+ "some data",
+ ),
)
@classmethod
diff --git a/lib/sqlalchemy/testing/suite/test_reflection.py b/lib/sqlalchemy/testing/suite/test_reflection.py
index 3c10a45f6..f728310d7 100644
--- a/lib/sqlalchemy/testing/suite/test_reflection.py
+++ b/lib/sqlalchemy/testing/suite/test_reflection.py
@@ -151,7 +151,10 @@ class QuotedNameArgumentTest(fixtures.TablesTest):
Column("related_id", Integer),
sa.PrimaryKeyConstraint("id", name="pk quote ' one"),
sa.Index("ix quote ' one", "name"),
- sa.UniqueConstraint("data", name="uq quote' one",),
+ sa.UniqueConstraint(
+ "data",
+ name="uq quote' one",
+ ),
sa.ForeignKeyConstraint(
["id"], ["related.id"], name="fk quote ' one"
),
@@ -170,7 +173,10 @@ class QuotedNameArgumentTest(fixtures.TablesTest):
Column("related_id", Integer),
sa.PrimaryKeyConstraint("id", name='pk quote " two'),
sa.Index('ix quote " two', "name"),
- sa.UniqueConstraint("data", name='uq quote" two',),
+ sa.UniqueConstraint(
+ "data",
+ name='uq quote" two',
+ ),
sa.ForeignKeyConstraint(
["id"], ["related.id"], name='fk quote " two'
),
@@ -1039,7 +1045,8 @@ class ComponentReflectionTest(fixtures.TablesTest):
"Skipped unsupported reflection of expression-based index t_idx"
):
eq_(
- insp.get_indexes("t"), expected,
+ insp.get_indexes("t"),
+ expected,
)
@testing.requires.index_reflects_included_columns
@@ -1098,7 +1105,8 @@ class ComponentReflectionTest(fixtures.TablesTest):
if testing.requires.index_reflects_included_columns.enabled:
expected[0]["include_columns"] = []
eq_(
- [idx for idx in indexes if idx["name"] == "user_tmp_ix"], expected,
+ [idx for idx in indexes if idx["name"] == "user_tmp_ix"],
+ expected,
)
@testing.requires.unique_constraint_reflection
@@ -1390,11 +1398,17 @@ class ComputedReflectionTest(fixtures.ComputedReflectionFixtureTest):
)
if testing.requires.computed_columns_virtual.enabled:
self.check_column(
- data, "computed_virtual", "normal+2", False,
+ data,
+ "computed_virtual",
+ "normal+2",
+ False,
)
if testing.requires.computed_columns_stored.enabled:
self.check_column(
- data, "computed_stored", "normal-42", True,
+ data,
+ "computed_stored",
+ "normal-42",
+ True,
)
@testing.requires.schemas
@@ -1414,11 +1428,17 @@ class ComputedReflectionTest(fixtures.ComputedReflectionFixtureTest):
)
if testing.requires.computed_columns_virtual.enabled:
self.check_column(
- data, "computed_virtual", "normal/2", False,
+ data,
+ "computed_virtual",
+ "normal/2",
+ False,
)
if testing.requires.computed_columns_stored.enabled:
self.check_column(
- data, "computed_stored", "normal*42", True,
+ data,
+ "computed_stored",
+ "normal*42",
+ True,
)
diff --git a/lib/sqlalchemy/testing/suite/test_results.py b/lib/sqlalchemy/testing/suite/test_results.py
index 1c1b20cf0..9484d41d0 100644
--- a/lib/sqlalchemy/testing/suite/test_results.py
+++ b/lib/sqlalchemy/testing/suite/test_results.py
@@ -408,7 +408,8 @@ class ServerSideCursorsTest(
)
eq_(
- result.fetchmany(5), [(i, "data%d" % i) for i in range(1, 6)],
+ result.fetchmany(5),
+ [(i, "data%d" % i) for i in range(1, 6)],
)
eq_(
result.fetchmany(10),
diff --git a/lib/sqlalchemy/testing/suite/test_select.py b/lib/sqlalchemy/testing/suite/test_select.py
index c199929a7..b0fb60c5f 100644
--- a/lib/sqlalchemy/testing/suite/test_select.py
+++ b/lib/sqlalchemy/testing/suite/test_select.py
@@ -1058,7 +1058,12 @@ class IdentityColumnTest(fixtures.TablesTest):
Column(
"id",
Integer,
- Identity(increment=-5, start=0, minvalue=-1000, maxvalue=0,),
+ Identity(
+ increment=-5,
+ start=0,
+ minvalue=-1000,
+ maxvalue=0,
+ ),
primary_key=True,
),
Column("desc", String(100)),
@@ -1067,13 +1072,16 @@ class IdentityColumnTest(fixtures.TablesTest):
@classmethod
def insert_data(cls, connection):
connection.execute(
- cls.tables.tbl_a.insert(), [{"desc": "a"}, {"desc": "b"}],
+ cls.tables.tbl_a.insert(),
+ [{"desc": "a"}, {"desc": "b"}],
)
connection.execute(
- cls.tables.tbl_b.insert(), [{"desc": "a"}, {"desc": "b"}],
+ cls.tables.tbl_b.insert(),
+ [{"desc": "a"}, {"desc": "b"}],
)
connection.execute(
- cls.tables.tbl_b.insert(), [{"id": 42, "desc": "c"}],
+ cls.tables.tbl_b.insert(),
+ [{"id": 42, "desc": "c"}],
)
def test_select_all(self, connection):
@@ -1102,7 +1110,8 @@ class IdentityColumnTest(fixtures.TablesTest):
def test_insert_always_error(self, connection):
def fn():
connection.execute(
- self.tables.tbl_a.insert(), [{"id": 200, "desc": "a"}],
+ self.tables.tbl_a.insert(),
+ [{"id": 200, "desc": "a"}],
)
assert_raises((DatabaseError, ProgrammingError), fn)
@@ -1204,7 +1213,8 @@ class IsOrIsNotDistinctFromTest(fixtures.TablesTest):
tbl.select(tbl.c.col_a.is_distinct_from(tbl.c.col_b))
).fetchall()
eq_(
- len(result), expected_row_count_for_is,
+ len(result),
+ expected_row_count_for_is,
)
expected_row_count_for_isnot = (
@@ -1214,5 +1224,6 @@ class IsOrIsNotDistinctFromTest(fixtures.TablesTest):
tbl.select(tbl.c.col_a.isnot_distinct_from(tbl.c.col_b))
).fetchall()
eq_(
- len(result), expected_row_count_for_isnot,
+ len(result),
+ expected_row_count_for_isnot,
)
diff --git a/lib/sqlalchemy/testing/suite/test_sequence.py b/lib/sqlalchemy/testing/suite/test_sequence.py
index 5a1876bc5..de970da53 100644
--- a/lib/sqlalchemy/testing/suite/test_sequence.py
+++ b/lib/sqlalchemy/testing/suite/test_sequence.py
@@ -24,7 +24,12 @@ class SequenceTest(fixtures.TablesTest):
Table(
"seq_pk",
metadata,
- Column("id", Integer, Sequence("tab_id_seq"), primary_key=True,),
+ Column(
+ "id",
+ Integer,
+ Sequence("tab_id_seq"),
+ primary_key=True,
+ ),
Column("data", String(50)),
)
@@ -109,17 +114,21 @@ class HasSequenceTest(fixtures.TablesTest):
"schema_seq", schema=config.test_schema, metadata=metadata
)
Table(
- "user_id_table", metadata, Column("id", Integer, primary_key=True),
+ "user_id_table",
+ metadata,
+ Column("id", Integer, primary_key=True),
)
def test_has_sequence(self, connection):
eq_(
- inspect(connection).has_sequence("user_id_seq"), True,
+ inspect(connection).has_sequence("user_id_seq"),
+ True,
)
def test_has_sequence_other_object(self, connection):
eq_(
- inspect(connection).has_sequence("user_id_table"), False,
+ inspect(connection).has_sequence("user_id_table"),
+ False,
)
@testing.requires.schemas
@@ -133,7 +142,8 @@ class HasSequenceTest(fixtures.TablesTest):
def test_has_sequence_neg(self, connection):
eq_(
- inspect(connection).has_sequence("some_sequence"), False,
+ inspect(connection).has_sequence("some_sequence"),
+ False,
)
@testing.requires.schemas
@@ -157,7 +167,8 @@ class HasSequenceTest(fixtures.TablesTest):
@testing.requires.schemas
def test_has_sequence_remote_not_in_default(self, connection):
eq_(
- inspect(connection).has_sequence("schema_seq"), False,
+ inspect(connection).has_sequence("schema_seq"),
+ False,
)
def test_get_sequence_names(self, connection):
@@ -194,5 +205,6 @@ class HasSequenceTestEmpty(fixtures.TestBase):
def test_get_sequence_names_no_sequence(self, connection):
eq_(
- inspect(connection).get_sequence_names(), [],
+ inspect(connection).get_sequence_names(),
+ [],
)
diff --git a/lib/sqlalchemy/testing/suite/test_types.py b/lib/sqlalchemy/testing/suite/test_types.py
index 8c6543700..da01aa484 100644
--- a/lib/sqlalchemy/testing/suite/test_types.py
+++ b/lib/sqlalchemy/testing/suite/test_types.py
@@ -621,9 +621,7 @@ class NumericTest(_LiteralRoundTripFixture, fixtures.TestBase):
@testing.requires.precision_numerics_enotation_large
def test_enotation_decimal_large(self):
- """test exceedingly large decimals.
-
- """
+ """test exceedingly large decimals."""
numbers = set(
[
@@ -962,7 +960,8 @@ class JSONTest(_LiteralRoundTripFixture, fixtures.TablesTest):
conn = connection
conn.execute(
- self.tables.data_table.insert(), {"name": "r1", "data": JSON.NULL},
+ self.tables.data_table.insert(),
+ {"name": "r1", "data": JSON.NULL},
)
eq_(
@@ -1158,13 +1157,18 @@ class JSONLegacyStringCastIndexTest(
# "cannot extract array element from a non-array", which is
# fixed in 9.4 but may exist in 9.3
self._test_index_criteria(
- and_(name == "r4", cast(col[1], String) == '"two"',), "r4",
+ and_(
+ name == "r4",
+ cast(col[1], String) == '"two"',
+ ),
+ "r4",
)
def test_string_cast_crit_mixed_path(self):
col = self.tables.data_table.c["data"]
self._test_index_criteria(
- cast(col[("key3", 1, "six")], String) == '"seven"', "r3",
+ cast(col[("key3", 1, "six")], String) == '"seven"',
+ "r3",
)
def test_string_cast_crit_string_path(self):
@@ -1180,7 +1184,10 @@ class JSONLegacyStringCastIndexTest(
col = self.tables.data_table.c["data"]
self._test_index_criteria(
- and_(name == "r6", cast(col["b"], String) == '"some value"',),
+ and_(
+ name == "r6",
+ cast(col["b"], String) == '"some value"',
+ ),
"r6",
)
diff --git a/lib/sqlalchemy/testing/warnings.py b/lib/sqlalchemy/testing/warnings.py
index dbe22bb8d..5704cf2a6 100644
--- a/lib/sqlalchemy/testing/warnings.py
+++ b/lib/sqlalchemy/testing/warnings.py
@@ -119,7 +119,9 @@ def setup_filters():
r"The Session.begin.subtransactions flag is deprecated",
]:
warnings.filterwarnings(
- "ignore", message=msg, category=sa_exc.RemovedIn20Warning,
+ "ignore",
+ message=msg,
+ category=sa_exc.RemovedIn20Warning,
)
try: