Skip to content

Commit 1979971

Browse files
committed
ruff format
1 parent 0c44f7d commit 1979971

1 file changed

Lines changed: 29 additions & 20 deletions

File tree

‎tests/test_cursor.py‎

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from MySQLdb.constants import ER
44
from configdb import connection_factory
55

6+
67
_conns = []
78
_tables = []
89

@@ -56,9 +57,9 @@ def test_executemany():
5657
"INSERT INTO TEST (ID, NAME) VALUES (%(id_name)s, %(name)s) ON duplicate update"
5758
)
5859
assert m is not None, "error parse %(id_name)s"
59-
assert (
60-
m.group(3) == " ON duplicate update"
61-
), "group 3 not ON duplicate update, bug in RE_INSERT_VALUES?"
60+
assert m.group(3) == " ON duplicate update", (
61+
"group 3 not ON duplicate update, bug in RE_INSERT_VALUES?"
62+
)
6263

6364
# https://github.com/PyMySQL/mysqlclient-python/issues/178
6465
m = MySQLdb.cursors.RE_INSERT_VALUES.match(
@@ -74,29 +75,31 @@ def test_executemany():
7475
# list args
7576
data = [(i,) for i in range(10)]
7677
cursor.executemany("insert into test (data) values (%s)", data)
77-
assert cursor._executed.endswith(
78-
b",(7),(8),(9)"
79-
), "execute many with %s not in one query"
78+
assert cursor._executed.endswith(b",(7),(8),(9)"), (
79+
"execute many with %s not in one query"
80+
)
8081

8182
# dict args
8283
data_dict = [{"data": i} for i in range(10)]
8384
cursor.executemany("insert into test (data) values (%(data)s)", data_dict)
84-
assert cursor._executed.endswith(
85-
b",(7),(8),(9)"
86-
), "execute many with %(data)s not in one query"
85+
assert cursor._executed.endswith(b",(7),(8),(9)"), (
86+
"execute many with %(data)s not in one query"
87+
)
8788

8889
# %% in column set
89-
cursor.execute("""\
90+
cursor.execute(
91+
"""\
9092
CREATE TABLE percent_test (
9193
`A%` INTEGER,
92-
`B%` INTEGER)""")
94+
`B%` INTEGER)"""
95+
)
9396
try:
9497
q = "INSERT INTO percent_test (`A%%`, `B%%`) VALUES (%s, %s)"
9598
assert MySQLdb.cursors.RE_INSERT_VALUES.match(q) is not None
9699
cursor.executemany(q, [(3, 4), (5, 6)])
97-
assert cursor._executed.endswith(
98-
b"(3, 4),(5, 6)"
99-
), "executemany with %% not in one query"
100+
assert cursor._executed.endswith(b"(3, 4),(5, 6)"), (
101+
"executemany with %% not in one query"
102+
)
100103
finally:
101104
cursor.execute("DROP TABLE IF EXISTS percent_test")
102105

@@ -192,23 +195,27 @@ def test_cursor_discard_result(Cursor):
192195
conn = connect()
193196
cursor = conn.cursor(Cursor)
194197

195-
cursor.execute("""\
198+
cursor.execute(
199+
"""\
196200
CREATE TABLE test_cursor_discard_result (
197201
id INTEGER PRIMARY KEY AUTO_INCREMENT,
198202
data VARCHAR(100)
199-
)""")
203+
)"""
204+
)
200205
_tables.append("test_cursor_discard_result")
201206

202207
cursor.executemany(
203208
"INSERT INTO test_cursor_discard_result (id, data) VALUES (%s, %s)",
204209
[(i, f"row {i}") for i in range(1, 101)],
205210
)
206211

207-
cursor.execute("""\
212+
cursor.execute(
213+
"""\
208214
SELECT * FROM test_cursor_discard_result WHERE id <= 10;
209215
SELECT * FROM test_cursor_discard_result WHERE id BETWEEN 11 AND 20;
210216
SELECT * FROM test_cursor_discard_result WHERE id BETWEEN 21 AND 30;
211-
""")
217+
"""
218+
)
212219
cursor.nextset()
213220
assert cursor.fetchone() == (11, "row 11")
214221

@@ -224,12 +231,14 @@ def test_binary_prefix():
224231
cursor = conn.cursor()
225232

226233
cursor.execute("DROP TABLE IF EXISTS test_binary_prefix")
227-
cursor.execute("""\
234+
cursor.execute(
235+
"""\
228236
CREATE TABLE test_binary_prefix (
229237
id INTEGER NOT NULL AUTO_INCREMENT,
230238
json JSON NOT NULL,
231239
PRIMARY KEY (id)
232-
) CHARSET=utf8mb4""")
240+
) CHARSET=utf8mb4"""
241+
)
233242

234243
cursor.executemany(
235244
"INSERT INTO test_binary_prefix (id, json) VALUES (%(id)s, %(json)s)",

0 commit comments

Comments
 (0)