diff --git a/tests/__init__.py b/tests/__init__.py index 490f5d1..26c6483 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -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() diff --git a/tests/types/test_country.py b/tests/types/test_country.py index 83607a7..07821ad 100644 --- a/tests/types/test_country.py +++ b/tests/types/test_country.py @@ -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'))