Add flake8 to test matrix

This commit is contained in:
Konsta Vesterinen
2015-03-17 14:14:07 +02:00
parent 45dd0ea6ac
commit b7a856ae6c
23 changed files with 57 additions and 182 deletions

View File

@@ -33,4 +33,5 @@ install:
- pip install -e .[$EXTRAS]
script:
- flake8 sqlalchemy_utils tests
- py.test

View File

@@ -36,6 +36,7 @@ extras_require = {
'pytz>=2014.2',
'python-dateutil>=2.2',
'pymysql',
'flake8>=2.4.0'
],
'anyjson': ['anyjson>=0.3.3'],
'babel': ['Babel>=1.3'],

View File

@@ -1,16 +1,16 @@
from .aggregates import aggregated
from .asserts import (
from .aggregates import aggregated # noqa
from .asserts import ( # noqa
assert_min_value,
assert_max_length,
assert_max_value,
assert_nullable,
assert_non_nullable
)
from .batch import batch_fetch, with_backrefs
from .decorators import generates
from .exceptions import ImproperlyConfigured
from .expression_parser import ExpressionParser
from .functions import (
from .batch import batch_fetch, with_backrefs # noqa
from .decorators import generates # noqa
from .exceptions import ImproperlyConfigured # noqa
from .expression_parser import ExpressionParser # noqa
from .functions import ( # noqa
analyze,
create_database,
create_mock_engine,
@@ -44,18 +44,18 @@ from .functions import (
sort_query,
table_name,
)
from .i18n import TranslationHybrid
from .listeners import (
from .i18n import TranslationHybrid # noqa
from .listeners import ( # noqa
auto_delete_orphans,
coercion_listener,
force_auto_coercion,
force_instant_defaults
)
from .generic import generic_relationship
from .proxy_dict import ProxyDict, proxy_dict
from .observer import observes
from .query_chain import QueryChain
from .types import (
from .generic import generic_relationship # noqa
from .proxy_dict import ProxyDict, proxy_dict # noqa
from .observer import observes # noqa
from .query_chain import QueryChain # noqa
from .types import ( # noqa
ArrowType,
Choice,
ChoiceType,
@@ -85,86 +85,7 @@ from .types import (
UUIDType,
WeekDaysType
)
from .models import Timestamp
from .models import Timestamp # noqa
__version__ = '0.29.8'
__all__ = (
aggregated,
analyze,
assert_max_length,
assert_non_nullable,
assert_nullable,
auto_delete_orphans,
batch_fetch,
coercion_listener,
create_database,
create_mock_engine,
database_exists,
dependent_objects,
drop_database,
escape_like,
force_auto_coercion,
force_instant_defaults,
generates,
generic_relationship,
get_bind,
get_column_key,
get_columns,
get_declarative_base,
get_hybrid_properties,
get_mapper,
get_query_entities,
get_primary_keys,
get_referencing_foreign_keys,
get_tables,
group_foreign_keys,
has_changes,
has_index,
identity,
instrumented_list,
is_loaded,
merge_references,
mock_engine,
naturally_equivalent,
proxy_dict,
render_expression,
render_statement,
sort_query,
table_name,
with_backrefs,
ArrowType,
Choice,
ChoiceType,
ColorType,
Country,
CountryType,
DateRangeType,
DateTimeRangeType,
EmailType,
EncryptedType,
ExpressionParser,
ImproperlyConfigured,
InstrumentedList,
IntRangeType,
IPAddressType,
JSONType,
LocaleType,
NumericRangeType,
Password,
PasswordType,
PhoneNumber,
PhoneNumberType,
ProxyDict,
QueryChain,
ScalarListException,
ScalarListType,
Timestamp,
TimezoneType,
TSVectorType,
URLType,
UUIDType,
WeekDaysType,
)

View File

@@ -1,5 +1,7 @@
"""Global SQLAlchemy-Utils exception classes.
"""
Global SQLAlchemy-Utils exception classes.
"""
class ImproperlyConfigured(Exception):
"""

View File

@@ -1,11 +1,11 @@
from .mock import create_mock_engine, mock_engine
from .render import render_expression, render_statement
from .sort_query import (
from .mock import create_mock_engine, mock_engine # noqa
from .render import render_expression, render_statement # noqa
from .sort_query import ( # noqa
make_order_by_deterministic,
sort_query,
QuerySorterException
)
from .database import (
from .database import ( # noqa
analyze,
create_database,
database_exists,
@@ -16,7 +16,7 @@ from .database import (
is_auto_assigned_date_column,
json_sql
)
from .foreign_keys import (
from .foreign_keys import ( # noqa
dependent_objects,
get_referencing_foreign_keys,
group_foreign_keys,
@@ -24,7 +24,7 @@ from .foreign_keys import (
merge_references,
non_indexed_foreign_keys,
)
from .orm import (
from .orm import ( # noqa
get_bind,
get_class_by_table,
get_column_key,
@@ -43,40 +43,3 @@ from .orm import (
quote,
table_name,
)
__all__ = (
'create_database',
'create_mock_engine',
'database_exists',
'dependent_objects',
'drop_database',
'escape_like',
'get_bind',
'get_class_by_table',
'get_columns',
'get_declarative_base',
'get_hybrid_properties',
'get_mapper',
'get_query_entities',
'get_primary_keys',
'get_referencing_foreign_keys',
'get_tables',
'getdotattr',
'group_foreign_keys',
'has_changes',
'identity',
'is_loaded',
'is_auto_assigned_date_column',
'is_indexed_foreign_key',
'json_sql',
'make_order_by_deterministic',
'mock_engine',
'naturally_equivalent',
'non_indexed_foreign_keys',
'QuerySorterException',
'quote',
'render_expression',
'render_statement',
'sort_query',
'table_name',
)

View File

@@ -1,2 +1,2 @@
from .chained_join import chained_join
from .select_aggregate import select_aggregate
from .chained_join import chained_join # noqa
from .select_aggregate import select_aggregate # noqa

View File

@@ -1,4 +1,3 @@
import six
from sqlalchemy import types
from sqlalchemy_utils.exceptions import ImproperlyConfigured
from sqlalchemy_utils.utils import str_coercible
@@ -46,8 +45,9 @@ class PhoneNumber(BasePhoneNumber):
italian_leading_zero=self._phone_number.italian_leading_zero,
raw_input=self._phone_number.raw_input,
country_code_source=self._phone_number.country_code_source,
preferred_domestic_carrier_code=
self._phone_number.preferred_domestic_carrier_code
preferred_domestic_carrier_code=(
self._phone_number.preferred_domestic_carrier_code
)
)
self.national = phonenumbers.format_number(
self._phone_number,

View File

@@ -29,8 +29,8 @@ class URLType(types.TypeDecorator, ScalarCoercible):
user = User(website=u'www.example.com')
# website is coerced to furl object, hence all nice furl operations come
# available
# website is coerced to furl object, hence all nice furl operations
# come available
user.website.args['some_argument'] = '12'
print user.website

View File

@@ -7,7 +7,9 @@ class TestAggregatesWithManyToManyRelationships(TestCase):
dns = 'postgres://postgres@localhost/sqlalchemy_utils_test'
def create_models(self):
user_group = sa.Table('user_group', self.Base.metadata,
user_group = sa.Table(
'user_group',
self.Base.metadata,
sa.Column('user_id', sa.Integer, sa.ForeignKey('user.id')),
sa.Column('group_id', sa.Integer, sa.ForeignKey('group.id'))
)

View File

@@ -3,6 +3,7 @@ import sqlalchemy as sa
from sqlalchemy_utils import aggregated
from tests import TestCase
class Test3LevelDeepOneToMany(TestCase):
dns = 'postgres://postgres@localhost/sqlalchemy_utils_test'

View File

@@ -1,7 +0,0 @@
import sqlalchemy as sa
from tests import TestCase
from sqlalchemy_utils.functions import (
render_statement,
render_expression,
mock_engine
)

View File

@@ -5,7 +5,7 @@ from flexmock import flexmock
from pytest import mark
pymysql = None
try:
import pymysql
import pymysql # noqa
except ImportError:
pass

View File

@@ -91,7 +91,10 @@ class TestGetQueryEntities(TestCase):
).label('number_of_articles')
query = self.session.query(self.Article, number_of_articles)
assert list(get_query_entities(query)) == [self.Article, number_of_articles]
assert list(get_query_entities(query)) == [
self.Article,
number_of_articles
]
def test_aliased_entity(self):
alias = sa.orm.aliased(self.Article)

View File

@@ -1,11 +1,7 @@
import sqlalchemy as sa
from sqlalchemy_utils.aggregates import select_aggregate
from tests import TestCase
from tests.mixins import (
ThreeLevelDeepManyToMany,
ThreeLevelDeepOneToMany,
ThreeLevelDeepOneToOne,
)
from tests.mixins import ThreeLevelDeepManyToMany
def normalize(sql):

View File

@@ -40,7 +40,7 @@ class TestExpressionParser(TestCase):
assert str(expr) == 'category.name IN (:name_1, :name_2)'
def test_boolean_expression(self):
expr = self.parser(self.User.name == False)
expr = self.parser(self.User.name == False) # noqa
assert str(expr) == 'category.name = 0'
def test_label(self):

View File

@@ -119,7 +119,6 @@ class TestGeneratesWithSourcePath(DeepPathGeneratesTestCase):
def copy_locale(self, document):
return document.locale
self.Document = Document
self.Section = Section
self.SubSection = SubSection

View File

@@ -1,12 +1,11 @@
from flexmock import flexmock
from pytest import mark
import sqlalchemy as sa
from sqlalchemy_utils import ColorType
from sqlalchemy_utils.types import color
from sqlalchemy_utils import ColorType, types # noqa
from tests import TestCase
@mark.skipif('color.python_colour_type is None')
@mark.skipif('types.color.python_colour_type is None')
class TestColorType(TestCase):
def create_models(self):
class Document(self.Base):

View File

@@ -4,7 +4,7 @@ import pytest
from pytest import mark
cryptography = None
try:
import cryptography
import cryptography # noqa
except ImportError:
pass

View File

@@ -35,7 +35,7 @@ class NumberRangeTestCase(TestCase):
def test_nullify_range(self):
building = self.create_building(None)
assert building.persons_at_night == None
assert building.persons_at_night is None
def test_update_with_none(self):
interval = intervals.IntInterval('(,)')

View File

@@ -52,6 +52,7 @@ class JSONTestCase(TestCase):
class TestSqliteJSONType(JSONTestCase):
pass
@mark.skipif('json.json is None')
class TestPostgresJSONType(JSONTestCase):
dns = 'postgres://postgres@localhost/sqlalchemy_utils_test'

View File

@@ -2,11 +2,10 @@ from pytest import mark
import sqlalchemy as sa
from tests import TestCase
from sqlalchemy import inspect
from sqlalchemy_utils.types import password
from sqlalchemy_utils import Password, PasswordType
from sqlalchemy_utils import Password, PasswordType, types # noqa
@mark.skipif('password.passlib is None')
@mark.skipif('types.password.passlib is None')
class TestPasswordType(TestCase):
def create_models(self):
class User(self.Base):
@@ -142,12 +141,12 @@ class TestPasswordType(TestCase):
obj.password = None
assert obj.password is None
assert obj.password == None
assert obj.password == None # noqa
obj.password = 'b'
assert obj.password is not None
assert obj.password != None
assert obj.password != None # noqa
def test_check_and_update_persist(self):
"""

View File

@@ -3,11 +3,10 @@ import sqlalchemy as sa
from pytest import mark
from tests import TestCase
from sqlalchemy_utils import PhoneNumberType, PhoneNumber
from sqlalchemy_utils.types import phone_number
from sqlalchemy_utils import PhoneNumberType, PhoneNumber, types # noqa
@mark.skipif('phone_number.phonenumbers is None')
@mark.skipif('types.phone_number.phonenumbers is None')
class TestPhoneNumber(object):
def setup_method(self, method):
self.valid_phone_numbers = [
@@ -48,13 +47,13 @@ class TestPhoneNumber(object):
def test_phone_number_str_repr(self):
number = PhoneNumber('+358401234567')
if six.PY2:
assert unicode(number) == number.national
assert unicode(number) == number.national # noqa
assert str(number) == number.national.encode('utf-8')
else:
assert str(number) == number.national
@mark.skipif('phone_number.phonenumbers is None')
@mark.skipif('types.phone_number.phonenumbers is None')
class TestPhoneNumberType(TestCase):
def create_models(self):

View File

@@ -1,12 +1,7 @@
from pytest import mark
import six
import sqlalchemy as sa
from sqlalchemy_utils.types import timezone
from tests import TestCase
import dateutil
import pytz
class TestTimezoneType(TestCase):
def create_models(self):