Skip to content

Commit

Permalink
provide active language fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivo van der Wijk committed Nov 14, 2013
1 parent e1357e4 commit adb1756
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
9 changes: 9 additions & 0 deletions wheelcms_axle/tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,12 @@ def fin():
settings.FALLBACK = old_fallback
request.addfinalizer(fin)

from django.utils import translation

@pytest.fixture()
def active_language(request):
old_lang = translation.get_language()
def fin():
translation.activate(old_lang)
request.addfinalizer(fin)

4 changes: 2 additions & 2 deletions wheelcms_axle/tests/test_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,9 +581,9 @@ def test_reorder_after(self, client):
assert n1.position > n3.position
assert n3.position > n2.position

from .fixtures import multilang_ENNL
from .fixtures import multilang_ENNL, active_language

@pytest.mark.usefixtures("multilang_ENNL")
@pytest.mark.usefixtures("multilang_ENNL", "active_language")
class TestTranslations(object):
def test_translated(self, client):
""" /a can point to either dutch or english content on different
Expand Down
4 changes: 2 additions & 2 deletions wheelcms_axle/tests/test_toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,9 @@ def test_clipboard_copy(self, client):
assert set(clipboard['items']) == set((t1, t2))

from django.utils import translation
from .fixtures import multilang_ENNLFR
from .fixtures import multilang_ENNLFR, active_language

@pytest.mark.usefixtures("localtyperegistry", "multilang_ENNLFR")
@pytest.mark.usefixtures("localtyperegistry", "multilang_ENNLFR", "active_language")
class TestTranslations(object):
types = (Type1Type, Type2Type)

Expand Down
6 changes: 3 additions & 3 deletions wheelcms_axle/tests/test_translations.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from wheelcms_axle.node import Node, DuplicatePathException
from django.utils import translation
from .fixtures import multilang_ENNLFR
from .fixtures import multilang_ENNLFR, active_language

import pytest


@pytest.mark.usefixtures("multilang_ENNLFR")
@pytest.mark.usefixtures("multilang_ENNLFR", "active_language")
class TestRootNode(object):
def test_disabled(self, client):
""" multi language support disabled """
Expand Down Expand Up @@ -45,7 +45,7 @@ def test_default(self, client):

## root cannot be renamed

@pytest.mark.usefixtures("multilang_ENNLFR")
@pytest.mark.usefixtures("multilang_ENNLFR", "active_language")
class TestNode(object):
def test_node(self, client):
translation.activate('en')
Expand Down

0 comments on commit adb1756

Please sign in to comment.