summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2018-12-30 23:53:36 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2019-01-05 12:53:38 -0500
commiteba16588f2e41d458eb982688140d1cb0b89b27f (patch)
tree0dc8b4c673ee0ad381b28a45cebbdbd2b3671883 /test
parent6673a213daa02ade815d00a19e39edc6cee1466a (diff)
downloadsqlalchemy-eba16588f2e41d458eb982688140d1cb0b89b27f.tar.gz
partial cherry-pick of master flake8. clean cherrypick for lib and test,
manually merged exaples. Change-Id: I9532d3b13d13f2769e6ca48eea23dd7d4041f68f (cherry picked from commit e3bdd80c6661c0e95fb67998c57540be667ce761)
Diffstat (limited to 'test')
-rw-r--r--test/dialect/test_suite.py2
-rw-r--r--test/orm/test_composites.py4
-rw-r--r--test/orm/test_deprecations.py76
-rw-r--r--test/orm/test_expire.py2
-rw-r--r--test/orm/test_generative.py2
-rw-r--r--test/orm/test_versioning.py2
-rw-r--r--test/sql/test_cte.py2
-rw-r--r--test/sql/test_operators.py8
-rw-r--r--test/sql/test_quote.py24
9 files changed, 64 insertions, 58 deletions
diff --git a/test/dialect/test_suite.py b/test/dialect/test_suite.py
index d4e753656..bf58c6fcc 100644
--- a/test/dialect/test_suite.py
+++ b/test/dialect/test_suite.py
@@ -1 +1 @@
-from sqlalchemy.testing.suite import *
+from sqlalchemy.testing.suite import * # noqa
diff --git a/test/orm/test_composites.py b/test/orm/test_composites.py
index 40254dbca..3fef87a0e 100644
--- a/test/orm/test_composites.py
+++ b/test/orm/test_composites.py
@@ -496,8 +496,8 @@ class PrimaryKeyTest(fixtures.MappedTest):
graphs = cls.tables.graphs
class Version(cls.Comparable):
- def __init__(self, id, version):
- self.id = id
+ def __init__(self, id_, version):
+ self.id = id_
self.version = version
def __composite_values__(self):
diff --git a/test/orm/test_deprecations.py b/test/orm/test_deprecations.py
index 120e59c1e..195012b99 100644
--- a/test/orm/test_deprecations.py
+++ b/test/orm/test_deprecations.py
@@ -4,6 +4,12 @@ Collects specimens of old ORM code and explicitly covers the recommended
modern (i.e. not deprecated) alternative to them. The tests snippets here can
be migrated directly to the wiki, docs, etc.
+.. deprecated::
+
+ This test suite is interested in extremely old (pre 0.5) patterns
+ and in modern use illustrates trivial use cases that don't need
+ an additional test suite.
+
"""
from sqlalchemy import ForeignKey
from sqlalchemy import func
@@ -20,7 +26,7 @@ from sqlalchemy.testing.schema import Table
class QueryAlternativesTest(fixtures.MappedTest):
- '''Collects modern idioms for Queries
+ r'''Collects modern idioms for Queries
The docstring for each test case serves as miniature documentation about
the deprecated use case, and the test body illustrates (and covers) the
@@ -30,22 +36,22 @@ class QueryAlternativesTest(fixtures.MappedTest):
cases remain useful to readers even after the deprecated method has been
removed from the modern codebase.
- Format:
+ Format::
- def test_deprecated_thing(self):
- """Query.methodname(old, arg, **signature)
+ def test_deprecated_thing(self):
+ """Query.methodname(old, arg, **signature)
- output = session.query(User).deprecatedmethod(inputs)
+ output = session.query(User).deprecatedmethod(inputs)
- """
+ """
- # 0.4+
- output = session.query(User).newway(inputs)
- assert output is correct
+ # 0.4+
+ output = session.query(User).newway(inputs)
+ assert output is correct
- # 0.5+
- output = session.query(User).evennewerway(inputs)
- assert output is correct
+ # 0.5+
+ output = session.query(User).evennewerway(inputs)
+ assert output is correct
'''
@@ -169,11 +175,11 @@ class QueryAlternativesTest(fixtures.MappedTest):
# 0.5.0
maxes = list(session.query(Address).values(func.max(Address.bounces)))
- max = maxes[0][0]
- assert max == 10
+ max_ = maxes[0][0]
+ assert max_ == 10
- max = session.query(func.max(Address.bounces)).one()[0]
- assert max == 10
+ max_ = session.query(func.max(Address.bounces)).one()[0]
+ assert max_ == 10
def test_apply_min(self):
"""Query.apply_min(col)
@@ -188,11 +194,11 @@ class QueryAlternativesTest(fixtures.MappedTest):
# 0.5.0
mins = list(session.query(Address).values(func.min(Address.bounces)))
- min = mins[0][0]
- assert min == 0
+ min_ = mins[0][0]
+ assert min_ == 0
- min = session.query(func.min(Address.bounces)).one()[0]
- assert min == 0
+ min_ = session.query(func.min(Address.bounces)).one()[0]
+ assert min_ == 0
def test_apply_avg(self):
"""Query.apply_avg(col)
@@ -231,7 +237,7 @@ class QueryAlternativesTest(fixtures.MappedTest):
assert avg == 11
def test_count_by(self):
- """Query.count_by(*args, **params)
+ r"""Query.count_by(\*args, \**params)
num = session.query(Address).count_by(purpose='Personal')
@@ -255,7 +261,7 @@ class QueryAlternativesTest(fixtures.MappedTest):
assert num == 3, num
def test_count_whereclause(self):
- """Query.count(whereclause=None, params=None, **kwargs)
+ r"""Query.count(whereclause=None, params=None, \**kwargs)
num = session.query(Address).count(address_table.c.bounces > 1)
@@ -269,7 +275,7 @@ class QueryAlternativesTest(fixtures.MappedTest):
assert num == 1, num
def test_execute(self):
- """Query.execute(clauseelement, params=None, *args, **kwargs)
+ r"""Query.execute(clauseelement, params=None, \*args, \**kwargs)
users = session.query(User).execute(users_table.select())
@@ -283,7 +289,7 @@ class QueryAlternativesTest(fixtures.MappedTest):
assert len(users) == 4
def test_get_by(self):
- """Query.get_by(*args, **params)
+ r"""Query.get_by(\*args, \**params)
user = session.query(User).get_by(name='ed')
@@ -316,7 +322,7 @@ class QueryAlternativesTest(fixtures.MappedTest):
assert user.name == "fred"
def test_instances_entities(self):
- """Query.instances(cursor, *mappers_or_columns, **kwargs)
+ r"""Query.instances(cursor, \*mappers_or_columns, \**kwargs)
sel = users_table.join(addresses_table).select(use_labels=True)
res = session.query(User).instances(sel.execute(), Address)
@@ -340,7 +346,7 @@ class QueryAlternativesTest(fixtures.MappedTest):
assert isinstance(cola, User) and isinstance(colb, Address)
def test_join_by(self):
- """Query.join_by(*args, **params)
+ r"""Query.join_by(\*args, \**params)
TODO
"""
@@ -392,7 +398,7 @@ class QueryAlternativesTest(fixtures.MappedTest):
assert user.id == 1
def test_select(self):
- """Query.select(arg=None, **kwargs)
+ r"""Query.select(arg=None, \**kwargs)
users = session.query(User).select(users_table.c.name != None)
@@ -406,11 +412,11 @@ class QueryAlternativesTest(fixtures.MappedTest):
assert len(users) == 4
def test_select_by(self):
- """Query.select_by(*args, **params)
+ r"""Query.select_by(\*args, \**params)
users = session.query(User).select_by(name='fred')
- # 0.3 magic join on *_by methods
+ # 0.3 magic join on \*_by methods
users = session.query(User).select_by(email_address='fred@the.fred')
"""
@@ -442,7 +448,7 @@ class QueryAlternativesTest(fixtures.MappedTest):
assert len(users) == 1
def test_selectfirst(self):
- """Query.selectfirst(arg=None, **kwargs)
+ r"""Query.selectfirst(arg=None, \**kwargs)
bounced = session.query(Address).selectfirst(
addresses_table.c.bounces > 0)
@@ -457,7 +463,7 @@ class QueryAlternativesTest(fixtures.MappedTest):
assert bounced.bounces > 0
def test_selectfirst_by(self):
- """Query.selectfirst_by(*args, **params)
+ r"""Query.selectfirst_by(\*args, \**params)
onebounce = session.query(Address).selectfirst_by(bounces=1)
@@ -491,7 +497,7 @@ class QueryAlternativesTest(fixtures.MappedTest):
assert onebounce_user.name == "jack"
def test_selectone(self):
- """Query.selectone(arg=None, **kwargs)
+ r"""Query.selectone(arg=None, \**kwargs)
ed = session.query(User).selectone(users_table.c.name == 'ed')
@@ -535,7 +541,7 @@ class QueryAlternativesTest(fixtures.MappedTest):
)
def test_select_statement(self):
- """Query.select_statement(statement, **params)
+ r"""Query.select_statement(statement, \**params)
users = session.query(User).select_statement(users_table.select())
@@ -549,7 +555,7 @@ class QueryAlternativesTest(fixtures.MappedTest):
assert len(users) == 4
def test_select_text(self):
- """Query.select_text(text, **params)
+ r"""Query.select_text(text, \**params)
users = session.query(User).select_text('SELECT * FROM users_table')
@@ -567,7 +573,7 @@ class QueryAlternativesTest(fixtures.MappedTest):
assert len(users) == 4
def test_select_whereclause(self):
- """Query.select_whereclause(whereclause=None, params=None, **kwargs)
+ r"""Query.select_whereclause(whereclause=None, params=None, \**kwargs)
users = session,query(User).select_whereclause(users.c.name=='ed')
diff --git a/test/orm/test_expire.py b/test/orm/test_expire.py
index f688ca9dd..03ef7b03a 100644
--- a/test/orm/test_expire.py
+++ b/test/orm/test_expire.py
@@ -1397,7 +1397,7 @@ class PolymorphicExpireTest(fixtures.MappedTest):
sess.add(e1)
assert e1.name == "engineer1"
- def test_no_instance_key(self):
+ def test_no_instance_key_pk_absent(self):
Engineer = self.classes.Engineer
# same as test_no_instance_key, but the PK columns
diff --git a/test/orm/test_generative.py b/test/orm/test_generative.py
index 1b7b99ee4..abc666af1 100644
--- a/test/orm/test_generative.py
+++ b/test/orm/test_generative.py
@@ -158,7 +158,7 @@ class GenerativeQueryTest(fixtures.MappedTest):
assert query.order_by(Foo.bar)[0].bar == 0
assert query.order_by(sa.desc(Foo.bar))[0].bar == 99
- def test_offset(self):
+ def test_offset_order_by(self):
Foo = self.classes.Foo
query = create_session().query(Foo)
diff --git a/test/orm/test_versioning.py b/test/orm/test_versioning.py
index b70430390..e54925f0b 100644
--- a/test/orm/test_versioning.py
+++ b/test/orm/test_versioning.py
@@ -1260,7 +1260,7 @@ class ServerVersioningTest(fixtures.MappedTest):
pass
@compiles(IncDefault)
- def compile(element, compiler, **kw):
+ def compile_(element, compiler, **kw):
# cache the counter value on the statement
# itself so the assertsql system gets the same
# value when it compiles the statement a second time
diff --git a/test/sql/test_cte.py b/test/sql/test_cte.py
index af66beb6d..ed2787b0f 100644
--- a/test/sql/test_cte.py
+++ b/test/sql/test_cte.py
@@ -245,7 +245,7 @@ class CTETest(fixtures.TestBase, AssertsCompiledSQL):
def test_recursive_union_no_alias_two(self):
"""
- pg's example:
+ pg's example::
WITH RECURSIVE t(n) AS (
VALUES (1)
diff --git a/test/sql/test_operators.py b/test/sql/test_operators.py
index 304e16681..978d3101d 100644
--- a/test/sql/test_operators.py
+++ b/test/sql/test_operators.py
@@ -609,10 +609,10 @@ class ExtensionOperatorTest(fixtures.TestBase, testing.AssertsCompiledSQL):
class JSONIndexOpTest(fixtures.TestBase, testing.AssertsCompiledSQL):
def setUp(self):
class MyTypeCompiler(compiler.GenericTypeCompiler):
- def visit_mytype(self, type, **kw):
+ def visit_mytype(self, type_, **kw):
return "MYTYPE"
- def visit_myothertype(self, type, **kw):
+ def visit_myothertype(self, type_, **kw):
return "MYOTHERTYPE"
class MyCompiler(compiler.SQLCompiler):
@@ -726,10 +726,10 @@ class JSONIndexOpTest(fixtures.TestBase, testing.AssertsCompiledSQL):
class ArrayIndexOpTest(fixtures.TestBase, testing.AssertsCompiledSQL):
def setUp(self):
class MyTypeCompiler(compiler.GenericTypeCompiler):
- def visit_mytype(self, type, **kw):
+ def visit_mytype(self, type_, **kw):
return "MYTYPE"
- def visit_myothertype(self, type, **kw):
+ def visit_myothertype(self, type_, **kw):
return "MYOTHERTYPE"
class MyCompiler(compiler.SQLCompiler):
diff --git a/test/sql/test_quote.py b/test/sql/test_quote.py
index f7a04eae7..49dfbba9f 100644
--- a/test/sql/test_quote.py
+++ b/test/sql/test_quote.py
@@ -217,18 +217,18 @@ class QuoteTest(fixtures.TestBase, AssertsCompiledSQL):
"""test the quoting of labels.
If labels aren't quoted, a query in postgresql in particular will
- fail since it produces:
-
- SELECT
- LaLa.lowercase, LaLa."UPPERCASE", LaLa."MixedCase", LaLa."ASC"
- FROM (
- SELECT DISTINCT
- "WorstCase1".lowercase AS lowercase,
- "WorstCase1"."UPPERCASE" AS UPPERCASE,
- "WorstCase1"."MixedCase" AS MixedCase,
- "WorstCase1"."ASC" AS ASC
- FROM "WorstCase1"
- ) AS LaLa
+ fail since it produces::
+
+ SELECT
+ LaLa.lowercase, LaLa."UPPERCASE", LaLa."MixedCase", LaLa."ASC"
+ FROM (
+ SELECT DISTINCT
+ "WorstCase1".lowercase AS lowercase,
+ "WorstCase1"."UPPERCASE" AS UPPERCASE,
+ "WorstCase1"."MixedCase" AS MixedCase,
+ "WorstCase1"."ASC" AS ASC
+ FROM "WorstCase1"
+ ) AS LaLa
where the "UPPERCASE" column of "LaLa" doesn't exist.
"""