diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-01-05 22:42:08 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-01-05 23:51:34 -0500 |
| commit | 404e69426b05a82d905cbb3ad33adafccddb00dd (patch) | |
| tree | 05e05dc66772923a31842a7fa9869805be879338 /test/sql/test_functions.py | |
| parent | d229360a8d4071c2f150558897f37e13eb09f430 (diff) | |
| download | sqlalchemy-404e69426b05a82d905cbb3ad33adafccddb00dd.tar.gz | |
Assorted pre-Black fixes
Fixes to the test suite, a few errant imports, and setup.py:
- mysql and postgresql have unused 'json' imports; remove
- postgresql is exporting the 'json' symbol, remove
- make sure setup.py can find __version__ using " or '
- retry logic in provision create database for postgresql fixed
- refactor test_magazine to use cls.tables rather than globals
- remove unused class in test_scoping
- add a comment to test_deprecations that this test suite itself
is deprecated
- don't use mapper() and orm_mapper() in test_unitofwork, just
use mapper()
- remove dupe test_scalar_set_None test in test_attributes
- Python 2.7 and above includes unittest.SkipTest, remove pre-2.7
fallback
- use imported SkipTest in profiling
- declarative test_reflection tests with "reflectable_autoincrement"
already don't run on oracle or firebird; remove conditional logic
for these, which also removes an "id" symbol
- clean up test in test_functions, remove print statement
- remove dupe test_literal_processor_coercion_native_int_out_of_range
in test/sql/test_types.py
- fix psycopg2_hstore ref
Change-Id: I7b3444f8546aac82be81cd1e7b6d8b2ad6834fe6
Diffstat (limited to 'test/sql/test_functions.py')
| -rw-r--r-- | test/sql/test_functions.py | 85 |
1 files changed, 41 insertions, 44 deletions
diff --git a/test/sql/test_functions.py b/test/sql/test_functions.py index ffc72e9ee..6fba7519c 100644 --- a/test/sql/test_functions.py +++ b/test/sql/test_functions.py @@ -800,6 +800,7 @@ class ExecuteTest(fixtures.TestBase): ret.close() @engines.close_first + @testing.provide_metadata def test_update(self): """ Tests sending functions and SQL expressions to the VALUES and SET @@ -807,7 +808,7 @@ class ExecuteTest(fixtures.TestBase): get overridden. """ - meta = MetaData(testing.db) + meta = self.metadata t = Table('t1', meta, Column('id', Integer, Sequence('t1idseq', optional=True), primary_key=True), @@ -820,51 +821,47 @@ class ExecuteTest(fixtures.TestBase): Column('stuff', String(20), onupdate="thisisstuff") ) meta.create_all() - try: - t.insert(values=dict(value=func.length("one"))).execute() - assert t.select().execute().first()['value'] == 3 - t.update(values=dict(value=func.length("asfda"))).execute() - assert t.select().execute().first()['value'] == 5 - - r = t.insert(values=dict(value=func.length("sfsaafsda"))).execute() - id = r.inserted_primary_key[0] - assert t.select(t.c.id == id).execute().first()['value'] == 9 - t.update(values={t.c.value: func.length("asdf")}).execute() - assert t.select().execute().first()['value'] == 4 - t2.insert().execute() - t2.insert(values=dict(value=func.length("one"))).execute() - t2.insert(values=dict(value=func.length("asfda") + -19)).\ - execute(stuff="hi") - - res = exec_sorted(select([t2.c.value, t2.c.stuff])) - eq_(res, [(-14, 'hi'), (3, None), (7, None)]) - - t2.update(values=dict(value=func.length("asdsafasd"))).\ - execute(stuff="some stuff") - assert select([t2.c.value, t2.c.stuff]).execute().fetchall() == \ - [(9, "some stuff"), (9, "some stuff"), - (9, "some stuff")] - - t2.delete().execute() - - t2.insert(values=dict(value=func.length("one") + 8)).execute() - assert t2.select().execute().first()['value'] == 11 - - t2.update(values=dict(value=func.length("asfda"))).execute() - eq_( - select([t2.c.value, t2.c.stuff]).execute().first(), - (5, "thisisstuff") + t.insert(values=dict(value=func.length("one"))).execute() + assert t.select().execute().first()['value'] == 3 + t.update(values=dict(value=func.length("asfda"))).execute() + assert t.select().execute().first()['value'] == 5 + + r = t.insert(values=dict(value=func.length("sfsaafsda"))).execute() + id = r.inserted_primary_key[0] + assert t.select(t.c.id == id).execute().first()['value'] == 9 + t.update(values={t.c.value: func.length("asdf")}).execute() + assert t.select().execute().first()['value'] == 4 + t2.insert().execute() + t2.insert(values=dict(value=func.length("one"))).execute() + t2.insert(values=dict(value=func.length("asfda") + -19)).\ + execute(stuff="hi") + + res = exec_sorted(select([t2.c.value, t2.c.stuff])) + eq_(res, [(-14, 'hi'), (3, None), (7, None)]) + + t2.update(values=dict(value=func.length("asdsafasd"))).\ + execute(stuff="some stuff") + assert select([t2.c.value, t2.c.stuff]).execute().fetchall() == \ + [(9, "some stuff"), (9, "some stuff"), + (9, "some stuff")] + + t2.delete().execute() + + t2.insert(values=dict(value=func.length("one") + 8)).execute() + assert t2.select().execute().first()['value'] == 11 + + t2.update(values=dict(value=func.length("asfda"))).execute() + eq_( + select([t2.c.value, t2.c.stuff]).execute().first(), + (5, "thisisstuff") + ) + + t2.update(values={t2.c.value: func.length("asfdaasdf"), + t2.c.stuff: "foo"}).execute() + eq_(select([t2.c.value, t2.c.stuff]).execute().first(), + (9, "foo") ) - t2.update(values={t2.c.value: func.length("asfdaasdf"), - t2.c.stuff: "foo"}).execute() - print("HI", select([t2.c.value, t2.c.stuff]).execute().first()) - eq_(select([t2.c.value, t2.c.stuff]).execute().first(), - (9, "foo") - ) - finally: - meta.drop_all() - @testing.fails_on_everything_except('postgresql') def test_as_from(self): # TODO: shouldn't this work on oracle too ? |
