diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-01-06 01:14:26 -0500 |
|---|---|---|
| committer | mike bayer <mike_mp@zzzcomputing.com> | 2019-01-06 17:34:50 +0000 |
| commit | 1e1a38e7801f410f244e4bbb44ec795ae152e04e (patch) | |
| tree | 28e725c5c8188bd0cfd133d1e268dbca9b524978 /test/sql/test_rowcount.py | |
| parent | 404e69426b05a82d905cbb3ad33adafccddb00dd (diff) | |
| download | sqlalchemy-1e1a38e7801f410f244e4bbb44ec795ae152e04e.tar.gz | |
Run black -l 79 against all source files
This is a straight reformat run using black as is, with no edits
applied at all.
The black run will format code consistently, however in
some cases that are prevalent in SQLAlchemy code it produces
too-long lines. The too-long lines will be resolved in the
following commit that will resolve all remaining flake8 issues
including shadowed builtins, long lines, import order, unused
imports, duplicate imports, and docstring issues.
Change-Id: I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9
Diffstat (limited to 'test/sql/test_rowcount.py')
| -rw-r--r-- | test/sql/test_rowcount.py | 99 |
1 files changed, 58 insertions, 41 deletions
diff --git a/test/sql/test_rowcount.py b/test/sql/test_rowcount.py index ea29bcf7e..126e1f0cd 100644 --- a/test/sql/test_rowcount.py +++ b/test/sql/test_rowcount.py @@ -8,7 +8,7 @@ class FoundRowsTest(fixtures.TestBase, AssertsExecutionResults): """tests rowcount functionality""" - __requires__ = ('sane_rowcount', ) + __requires__ = ("sane_rowcount",) __backend__ = True @classmethod @@ -17,28 +17,35 @@ class FoundRowsTest(fixtures.TestBase, AssertsExecutionResults): metadata = MetaData(testing.db) employees_table = Table( - 'employees', metadata, + "employees", + metadata, Column( - 'employee_id', Integer, - Sequence('employee_id_seq', optional=True), primary_key=True), - Column('name', String(50)), - Column('department', String(1))) + "employee_id", + Integer, + Sequence("employee_id_seq", optional=True), + primary_key=True, + ), + Column("name", String(50)), + Column("department", String(1)), + ) metadata.create_all() def setup(self): global data - data = [('Angela', 'A'), - ('Andrew', 'A'), - ('Anand', 'A'), - ('Bob', 'B'), - ('Bobette', 'B'), - ('Buffy', 'B'), - ('Charlie', 'C'), - ('Cynthia', 'C'), - ('Chris', 'C')] + data = [ + ("Angela", "A"), + ("Andrew", "A"), + ("Anand", "A"), + ("Bob", "B"), + ("Bobette", "B"), + ("Buffy", "B"), + ("Charlie", "C"), + ("Cynthia", "C"), + ("Chris", "C"), + ] i = employees_table.insert() - i.execute(*[{'name': n, 'department': d} for n, d in data]) + i.execute(*[{"name": n, "department": d} for n, d in data]) def teardown(self): employees_table.delete().execute() @@ -56,23 +63,26 @@ class FoundRowsTest(fixtures.TestBase, AssertsExecutionResults): def test_update_rowcount1(self): # WHERE matches 3, 3 rows changed department = employees_table.c.department - r = employees_table.update(department == 'C').execute(department='Z') + r = employees_table.update(department == "C").execute(department="Z") assert r.rowcount == 3 def test_update_rowcount2(self): # WHERE matches 3, 0 rows changed department = employees_table.c.department - r = employees_table.update(department == 'C').execute(department='C') + r = employees_table.update(department == "C").execute(department="C") assert r.rowcount == 3 @testing.skip_if( - testing.requires.oracle5x, - "unknown DBAPI error fixed in later version") + testing.requires.oracle5x, "unknown DBAPI error fixed in later version" + ) @testing.requires.sane_rowcount_w_returning def test_update_rowcount_return_defaults(self): department = employees_table.c.department - stmt = employees_table.update(department == 'C').values( - name=employees_table.c.department + 'Z').return_defaults() + stmt = ( + employees_table.update(department == "C") + .values(name=employees_table.c.department + "Z") + .return_defaults() + ) r = stmt.execute() assert r.rowcount == 3 @@ -81,7 +91,8 @@ class FoundRowsTest(fixtures.TestBase, AssertsExecutionResults): # test issue #3622, make sure eager rowcount is called for text with testing.db.connect() as conn: result = conn.execute( - "update employees set department='Z' where department='C'") + "update employees set department='Z' where department='C'" + ) eq_(result.rowcount, 3) def test_text_rowcount(self): @@ -90,43 +101,49 @@ class FoundRowsTest(fixtures.TestBase, AssertsExecutionResults): result = conn.execute( text( "update employees set department='Z' " - "where department='C'")) + "where department='C'" + ) + ) eq_(result.rowcount, 3) def test_delete_rowcount(self): # WHERE matches 3, 3 rows deleted department = employees_table.c.department - r = employees_table.delete(department == 'C').execute() + r = employees_table.delete(department == "C").execute() assert r.rowcount == 3 @testing.requires.sane_multi_rowcount def test_multi_update_rowcount(self): - stmt = employees_table.update().\ - where(employees_table.c.name == bindparam('emp_name')).\ - values(department="C") + stmt = ( + employees_table.update() + .where(employees_table.c.name == bindparam("emp_name")) + .values(department="C") + ) r = testing.db.execute( stmt, - [{"emp_name": "Bob"}, {"emp_name": "Cynthia"}, - {"emp_name": "nonexistent"}] + [ + {"emp_name": "Bob"}, + {"emp_name": "Cynthia"}, + {"emp_name": "nonexistent"}, + ], ) - eq_( - r.rowcount, 2 - ) + eq_(r.rowcount, 2) @testing.requires.sane_multi_rowcount def test_multi_delete_rowcount(self): - stmt = employees_table.delete().\ - where(employees_table.c.name == bindparam('emp_name')) + stmt = employees_table.delete().where( + employees_table.c.name == bindparam("emp_name") + ) r = testing.db.execute( stmt, - [{"emp_name": "Bob"}, {"emp_name": "Cynthia"}, - {"emp_name": "nonexistent"}] - ) - - eq_( - r.rowcount, 2 + [ + {"emp_name": "Bob"}, + {"emp_name": "Cynthia"}, + {"emp_name": "nonexistent"}, + ], ) + eq_(r.rowcount, 2) |
