Skip to content

Commit

Permalink
Do not override globals provided by extensions.
Browse files Browse the repository at this point in the history
Fixes #26, closes #27.
  • Loading branch information
miracle2k committed Feb 7, 2012
1 parent 0e2592f commit e325ad3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion coffin/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self, filters={}, globals={}, tests={}, loader=None, extensions=[],
# the proper priority), so we want to assign to these attributes.
self.filters = all_ext['filters'].copy()
self.filters.update(filters)
self.globals = all_ext['globals'].copy()
self.globals.update(all_ext['globals'])
self.globals.update(globals)
self.tests = all_ext['tests'].copy()
self.tests.update(tests)
Expand Down
13 changes: 7 additions & 6 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from os import path
import sys

def setup_package():
# setup Django with our test demo project
sys.path.insert(0, path.join(path.dirname(__file__), 'res', 'apps'))
from django.core.management import setup_environ
import settings
setup_environ(settings)
# Setup Django with our test demo project. We need to do this in global
# module code rather than setup_package(), because we want it to run
# before any module-wide imports in any of the test modules.
sys.path.insert(0, path.join(path.dirname(__file__), 'res', 'apps'))
from django.core.management import setup_environ
import settings
setup_environ(settings)
11 changes: 11 additions & 0 deletions tests/test_env.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""Test construction of the implicitly provided JinjaEnvironment,
in the common.py module.
"""

from coffin.common import get_env
from django.test.utils import override_settings


def test_i18n():
with override_settings(USE_I18N=True):
assert get_env().from_string('{{ _("test") }}').render() == 'test'

0 comments on commit e325ad3

Please sign in to comment.