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_unicode.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_unicode.py')
| -rw-r--r-- | test/sql/test_unicode.py | 214 |
1 files changed, 123 insertions, 91 deletions
diff --git a/test/sql/test_unicode.py b/test/sql/test_unicode.py index e29aea54f..fafdb03a3 100644 --- a/test/sql/test_unicode.py +++ b/test/sql/test_unicode.py @@ -9,7 +9,7 @@ from sqlalchemy.util import u, ue class UnicodeSchemaTest(fixtures.TestBase): - __requires__ = ('unicode_ddl',) + __requires__ = ("unicode_ddl",) __backend__ = True @classmethod @@ -17,53 +17,67 @@ class UnicodeSchemaTest(fixtures.TestBase): global metadata, t1, t2, t3 metadata = MetaData(testing.db) - t1 = Table(u('unitable1'), metadata, - Column(u('méil'), Integer, primary_key=True), - Column(ue('\u6e2c\u8a66'), Integer), - test_needs_fk=True, - ) + t1 = Table( + u("unitable1"), + metadata, + Column(u("méil"), Integer, primary_key=True), + Column(ue("\u6e2c\u8a66"), Integer), + test_needs_fk=True, + ) t2 = Table( - u('Unitéble2'), + u("Unitéble2"), metadata, + Column(u("méil"), Integer, primary_key=True, key="a"), Column( - u('méil'), - Integer, - primary_key=True, - key="a"), - Column( - ue('\u6e2c\u8a66'), + ue("\u6e2c\u8a66"), Integer, - ForeignKey( - u('unitable1.méil')), - key="b"), + ForeignKey(u("unitable1.méil")), + key="b", + ), test_needs_fk=True, ) # Few DBs support Unicode foreign keys - if testing.against('sqlite'): - t3 = Table(ue('\u6e2c\u8a66'), metadata, - Column(ue('\u6e2c\u8a66_id'), Integer, primary_key=True, - autoincrement=False), - Column(ue('unitable1_\u6e2c\u8a66'), Integer, - ForeignKey(ue('unitable1.\u6e2c\u8a66')) - ), - Column(u('Unitéble2_b'), Integer, - ForeignKey(u('Unitéble2.b')) - ), - Column(ue('\u6e2c\u8a66_self'), Integer, - ForeignKey(ue('\u6e2c\u8a66.\u6e2c\u8a66_id')) - ), - test_needs_fk=True, - ) + if testing.against("sqlite"): + t3 = Table( + ue("\u6e2c\u8a66"), + metadata, + Column( + ue("\u6e2c\u8a66_id"), + Integer, + primary_key=True, + autoincrement=False, + ), + Column( + ue("unitable1_\u6e2c\u8a66"), + Integer, + ForeignKey(ue("unitable1.\u6e2c\u8a66")), + ), + Column( + u("Unitéble2_b"), Integer, ForeignKey(u("Unitéble2.b")) + ), + Column( + ue("\u6e2c\u8a66_self"), + Integer, + ForeignKey(ue("\u6e2c\u8a66.\u6e2c\u8a66_id")), + ), + test_needs_fk=True, + ) else: - t3 = Table(ue('\u6e2c\u8a66'), metadata, - Column(ue('\u6e2c\u8a66_id'), Integer, primary_key=True, - autoincrement=False), - Column(ue('unitable1_\u6e2c\u8a66'), Integer), - Column(u('Unitéble2_b'), Integer), - Column(ue('\u6e2c\u8a66_self'), Integer), - test_needs_fk=True, - ) + t3 = Table( + ue("\u6e2c\u8a66"), + metadata, + Column( + ue("\u6e2c\u8a66_id"), + Integer, + primary_key=True, + autoincrement=False, + ), + Column(ue("unitable1_\u6e2c\u8a66"), Integer), + Column(u("Unitéble2_b"), Integer), + Column(ue("\u6e2c\u8a66_self"), Integer), + test_needs_fk=True, + ) metadata.create_all() @engines.close_first @@ -78,86 +92,104 @@ class UnicodeSchemaTest(fixtures.TestBase): metadata.drop_all() def test_insert(self): - t1.insert().execute({u('méil'): 1, ue('\u6e2c\u8a66'): 5}) - t2.insert().execute({u('a'): 1, u('b'): 1}) - t3.insert().execute({ue('\u6e2c\u8a66_id'): 1, - ue('unitable1_\u6e2c\u8a66'): 5, - u('Unitéble2_b'): 1, - ue('\u6e2c\u8a66_self'): 1}) + t1.insert().execute({u("méil"): 1, ue("\u6e2c\u8a66"): 5}) + t2.insert().execute({u("a"): 1, u("b"): 1}) + t3.insert().execute( + { + ue("\u6e2c\u8a66_id"): 1, + ue("unitable1_\u6e2c\u8a66"): 5, + u("Unitéble2_b"): 1, + ue("\u6e2c\u8a66_self"): 1, + } + ) assert t1.select().execute().fetchall() == [(1, 5)] assert t2.select().execute().fetchall() == [(1, 1)] assert t3.select().execute().fetchall() == [(1, 5, 1, 1)] def test_col_targeting(self): - t1.insert().execute({u('méil'): 1, ue('\u6e2c\u8a66'): 5}) - t2.insert().execute({u('a'): 1, u('b'): 1}) - t3.insert().execute({ue('\u6e2c\u8a66_id'): 1, - ue('unitable1_\u6e2c\u8a66'): 5, - u('Unitéble2_b'): 1, - ue('\u6e2c\u8a66_self'): 1}) + t1.insert().execute({u("méil"): 1, ue("\u6e2c\u8a66"): 5}) + t2.insert().execute({u("a"): 1, u("b"): 1}) + t3.insert().execute( + { + ue("\u6e2c\u8a66_id"): 1, + ue("unitable1_\u6e2c\u8a66"): 5, + u("Unitéble2_b"): 1, + ue("\u6e2c\u8a66_self"): 1, + } + ) row = t1.select().execute().first() - eq_(row[t1.c[u('méil')]], 1) - eq_(row[t1.c[ue('\u6e2c\u8a66')]], 5) + eq_(row[t1.c[u("méil")]], 1) + eq_(row[t1.c[ue("\u6e2c\u8a66")]], 5) row = t2.select().execute().first() - eq_(row[t2.c[u('a')]], 1) - eq_(row[t2.c[u('b')]], 1) + eq_(row[t2.c[u("a")]], 1) + eq_(row[t2.c[u("b")]], 1) row = t3.select().execute().first() - eq_(row[t3.c[ue('\u6e2c\u8a66_id')]], 1) - eq_(row[t3.c[ue('unitable1_\u6e2c\u8a66')]], 5) - eq_(row[t3.c[u('Unitéble2_b')]], 1) - eq_(row[t3.c[ue('\u6e2c\u8a66_self')]], 1) + eq_(row[t3.c[ue("\u6e2c\u8a66_id")]], 1) + eq_(row[t3.c[ue("unitable1_\u6e2c\u8a66")]], 5) + eq_(row[t3.c[u("Unitéble2_b")]], 1) + eq_(row[t3.c[ue("\u6e2c\u8a66_self")]], 1) def test_reflect(self): - t1.insert().execute({u('méil'): 2, ue('\u6e2c\u8a66'): 7}) - t2.insert().execute({u('a'): 2, u('b'): 2}) - t3.insert().execute({ue('\u6e2c\u8a66_id'): 2, - ue('unitable1_\u6e2c\u8a66'): 7, - u('Unitéble2_b'): 2, - ue('\u6e2c\u8a66_self'): 2}) + t1.insert().execute({u("méil"): 2, ue("\u6e2c\u8a66"): 7}) + t2.insert().execute({u("a"): 2, u("b"): 2}) + t3.insert().execute( + { + ue("\u6e2c\u8a66_id"): 2, + ue("unitable1_\u6e2c\u8a66"): 7, + u("Unitéble2_b"): 2, + ue("\u6e2c\u8a66_self"): 2, + } + ) meta = MetaData(testing.db) tt1 = Table(t1.name, meta, autoload=True) tt2 = Table(t2.name, meta, autoload=True) tt3 = Table(t3.name, meta, autoload=True) - tt1.insert().execute({u('méil'): 1, ue('\u6e2c\u8a66'): 5}) - tt2.insert().execute({u('méil'): 1, ue('\u6e2c\u8a66'): 1}) - tt3.insert().execute({ue('\u6e2c\u8a66_id'): 1, - ue('unitable1_\u6e2c\u8a66'): 5, - u('Unitéble2_b'): 1, - ue('\u6e2c\u8a66_self'): 1}) + tt1.insert().execute({u("méil"): 1, ue("\u6e2c\u8a66"): 5}) + tt2.insert().execute({u("méil"): 1, ue("\u6e2c\u8a66"): 1}) + tt3.insert().execute( + { + ue("\u6e2c\u8a66_id"): 1, + ue("unitable1_\u6e2c\u8a66"): 5, + u("Unitéble2_b"): 1, + ue("\u6e2c\u8a66_self"): 1, + } + ) self.assert_( - tt1.select( - order_by=desc( - u('méil'))).execute().fetchall() == [ - (2, 7), (1, 5)]) + tt1.select(order_by=desc(u("méil"))).execute().fetchall() + == [(2, 7), (1, 5)] + ) + self.assert_( + tt2.select(order_by=desc(u("méil"))).execute().fetchall() + == [(2, 2), (1, 1)] + ) self.assert_( - tt2.select( - order_by=desc( - u('méil'))).execute().fetchall() == [ - (2, 2), (1, 1)]) - self.assert_(tt3.select(order_by=desc(ue('\u6e2c\u8a66_id'))). - execute().fetchall() == - [(2, 7, 2, 2), (1, 5, 1, 1)]) + tt3.select(order_by=desc(ue("\u6e2c\u8a66_id"))) + .execute() + .fetchall() + == [(2, 7, 2, 2), (1, 5, 1, 1)] + ) def test_repr(self): m = MetaData() t = Table( - ue('\u6e2c\u8a66'), - m, - Column( - ue('\u6e2c\u8a66_id'), - Integer)) + ue("\u6e2c\u8a66"), m, Column(ue("\u6e2c\u8a66_id"), Integer) + ) # I hardly understand what's going on with the backslashes in # this one on py2k vs. py3k - eq_(repr(t), - ("Table('\\u6e2c\\u8a66', MetaData(bind=None), " - "Column('\\u6e2c\\u8a66_id', Integer(), table=<\u6e2c\u8a66>), " - "schema=None)")) + eq_( + repr(t), + ( + "Table('\\u6e2c\\u8a66', MetaData(bind=None), " + "Column('\\u6e2c\\u8a66_id', Integer(), table=<\u6e2c\u8a66>), " + "schema=None)" + ), + ) |
