Fixed i18n get_locale setting in tests
This commit is contained in:
@@ -6,7 +6,9 @@ from sqlalchemy.orm import sessionmaker
|
|||||||
from sqlalchemy.ext.declarative import declarative_base
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
from sqlalchemy.ext.hybrid import hybrid_property
|
from sqlalchemy.ext.hybrid import hybrid_property
|
||||||
|
|
||||||
from sqlalchemy_utils import InstrumentedList, coercion_listener, aggregates
|
from sqlalchemy_utils import (
|
||||||
|
InstrumentedList, coercion_listener, aggregates, i18n
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@sa.event.listens_for(sa.engine.Engine, 'before_cursor_execute')
|
@sa.event.listens_for(sa.engine.Engine, 'before_cursor_execute')
|
||||||
@@ -23,6 +25,13 @@ warnings.simplefilter('error', sa.exc.SAWarning)
|
|||||||
sa.event.listen(sa.orm.mapper, 'mapper_configured', coercion_listener)
|
sa.event.listen(sa.orm.mapper, 'mapper_configured', coercion_listener)
|
||||||
|
|
||||||
|
|
||||||
|
def get_locale():
|
||||||
|
class Locale():
|
||||||
|
territories = {'fi': 'Finland'}
|
||||||
|
|
||||||
|
return Locale()
|
||||||
|
|
||||||
|
|
||||||
class TestCase(object):
|
class TestCase(object):
|
||||||
dns = 'sqlite:///:memory:'
|
dns = 'sqlite:///:memory:'
|
||||||
|
|
||||||
@@ -38,6 +47,7 @@ class TestCase(object):
|
|||||||
Session = sessionmaker(bind=self.connection)
|
Session = sessionmaker(bind=self.connection)
|
||||||
self.session = Session()
|
self.session = Session()
|
||||||
sa.orm.configure_mappers()
|
sa.orm.configure_mappers()
|
||||||
|
i18n.get_locale = get_locale
|
||||||
|
|
||||||
def teardown_method(self, method):
|
def teardown_method(self, method):
|
||||||
aggregates.manager.reset()
|
aggregates.manager.reset()
|
||||||
|
@@ -1,18 +1,8 @@
|
|||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from sqlalchemy_utils import CountryType, Country, i18n
|
from sqlalchemy_utils import CountryType, Country
|
||||||
from tests import TestCase
|
from tests import TestCase
|
||||||
|
|
||||||
|
|
||||||
def get_locale():
|
|
||||||
class Locale():
|
|
||||||
territories = {'fi': 'Finland'}
|
|
||||||
|
|
||||||
return Locale()
|
|
||||||
|
|
||||||
|
|
||||||
i18n.get_locale = get_locale
|
|
||||||
|
|
||||||
|
|
||||||
class TestCountry(object):
|
class TestCountry(object):
|
||||||
def test_init(self):
|
def test_init(self):
|
||||||
assert Country(u'fi') == Country(Country(u'fi'))
|
assert Country(u'fi') == Country(Country(u'fi'))
|
||||||
|
Reference in New Issue
Block a user