Fixed i18n get_locale setting in tests

This commit is contained in:
Konsta Vesterinen
2013-11-13 15:17:01 +02:00
parent 68750921e8
commit 7294d45d99
2 changed files with 12 additions and 12 deletions

View File

@@ -6,7 +6,9 @@ from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
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')
@@ -23,6 +25,13 @@ warnings.simplefilter('error', sa.exc.SAWarning)
sa.event.listen(sa.orm.mapper, 'mapper_configured', coercion_listener)
def get_locale():
class Locale():
territories = {'fi': 'Finland'}
return Locale()
class TestCase(object):
dns = 'sqlite:///:memory:'
@@ -38,6 +47,7 @@ class TestCase(object):
Session = sessionmaker(bind=self.connection)
self.session = Session()
sa.orm.configure_mappers()
i18n.get_locale = get_locale
def teardown_method(self, method):
aggregates.manager.reset()

View File

@@ -1,18 +1,8 @@
import sqlalchemy as sa
from sqlalchemy_utils import CountryType, Country, i18n
from sqlalchemy_utils import CountryType, Country
from tests import TestCase
def get_locale():
class Locale():
territories = {'fi': 'Finland'}
return Locale()
i18n.get_locale = get_locale
class TestCountry(object):
def test_init(self):
assert Country(u'fi') == Country(Country(u'fi'))