[Python-modules-commits] [django-assets] 02/17: Import django-assets_0.12.orig.tar.gz

Michael Fladischer fladi at moszumanska.debian.org
Mon Aug 29 10:19:34 UTC 2016


This is an automated email from the git hooks/post-receive script.

fladi pushed a commit to branch master
in repository django-assets.

commit 7720f1113291e2a8fa283ecdf6a4849a17b45212
Author: Michael Fladischer <FladischerMichael at fladi.at>
Date:   Mon Aug 29 09:59:42 2016 +0200

    Import django-assets_0.12.orig.tar.gz
---
 .travis.yml                                 |  29 +++++---
 CHANGES                                     |   5 ++
 README.rst                                  |   2 +-
 django_assets/__init__.py                   |   4 +-
 django_assets/env.py                        | 102 +++++--------------------
 django_assets/finders.py                    |   7 +-
 django_assets/loaders.py                    |  38 +++++-----
 django_assets/management/commands/assets.py |  85 +++------------------
 django_assets/manifest.py                   |   2 -
 django_assets/pytest_plugin.py              |   1 -
 setup.py                                    |  15 +++-
 tests/__init__.py                           |   7 +-
 tests/helpers.py                            |  46 ------------
 tests/test_django.py                        |  80 +++++++++-----------
 tox.ini                                     | 111 +++-------------------------
 15 files changed, 134 insertions(+), 400 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 9702c45..50a1569 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,13 +1,24 @@
 language: python
-python:
-  - 2.6
-install: pip install tox
-script: tox -r
-notifications:
-  email:
-    - michael at elsdoerfer.com
+python: 2.7
+env:
+  - TOX_ENV=django18-py27
+  - TOX_ENV=django18-py33
+  - TOX_ENV=django18-py34
+  - TOX_ENV=django18-pypy
+
+  - TOX_ENV=django19-py27
+  - TOX_ENV=django19-py34
+  - TOX_ENV=django19-py35
+install:
+  - pip install tox
+script:
+  - tox -e $TOX_ENV
 branches:
   only:
     - master
-
-
+addons:
+  apt:
+    sources:
+      - deadsnakes
+    packages:
+      - python3.5
diff --git a/CHANGES b/CHANGES
index 304672f..a53a232 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,8 @@
+0.12 (2016-07-13)
+   - Support Django 1.8 (various contributors).
+   - Drop support for Django 1.6.
+   - Windows fixes.
+
 0.11 (2015-08-21)
     - Match webassets 0.11.
 
diff --git a/README.rst b/README.rst
index ab7db91..7f60256 100644
--- a/README.rst
+++ b/README.rst
@@ -2,6 +2,6 @@ Integrates the `webassets`_ library with Django, adding support for
 merging, minifying and compiling CSS and Javascript files.
 
 Documentation:
-    http://django-assets.readthedocs.org/
+    https://django-assets.readthedocs.io/
 
 .. _webassets: http://github.com/miracle2k/webassets
diff --git a/django_assets/__init__.py b/django_assets/__init__.py
index d71e3b6..d7966a3 100644
--- a/django_assets/__init__.py
+++ b/django_assets/__init__.py
@@ -5,8 +5,8 @@ from django_assets.env import register
 
 __all__ = ('Bundle', 'register')
 
-__version__ = (0, 11)
-__webassets_version__ = ('0.11',)
+__version__ = (0, 12)
+__webassets_version__ = ('>=0.11',)
 
 
 from django_assets import filter
diff --git a/django_assets/env.py b/django_assets/env.py
index 15ea0a7..03bff57 100644
--- a/django_assets/env.py
+++ b/django_assets/env.py
@@ -1,9 +1,12 @@
 import imp
 import threading
+from importlib import import_module
+
+from django.apps import apps
+from django.contrib.staticfiles import finders
 from django.conf import settings
 from webassets.env import (
     BaseEnvironment, ConfigStorage, Resolver, url_prefix_join)
-from webassets.exceptions import ImminentDeprecationWarning
 
 from django_assets.glob import Globber, has_magic
 
@@ -11,7 +14,6 @@ from django_assets.glob import Globber, has_magic
 __all__ = ('register',)
 
 
-
 class DjangoConfigStorage(ConfigStorage):
 
     _mapping = {
@@ -27,9 +29,6 @@ class DjangoConfigStorage(ConfigStorage):
     }
 
     def _transform_key(self, key):
-        # STATIC_* are the new Django 1.3 settings,
-        # MEDIA_* was used in earlier versions.
-
         if key.lower() == 'directory':
             if hasattr(settings, 'ASSETS_ROOT'):
                 return 'ASSETS_ROOT'
@@ -112,13 +111,6 @@ class DjangoResolver(Resolver):
         # The staticfiles finder system can't do globs, but we can
         # access the storages behind the finders, and glob those.
 
-        # We can't import too early because of unit tests
-        try:
-            from django.contrib.staticfiles import finders
-        except ImportError:
-            # Support pre-1.3 versions.
-            finders = None
-
         for finder in finders.get_finders():
             # Builtin finders use either one of those attributes,
             # though this does seem to be informal; custom finders
@@ -139,21 +131,12 @@ class DjangoResolver(Resolver):
         if not self.use_staticfiles:
             return Resolver.search_for_source(self, ctx, item)
 
-        # We can't import too early because of unit tests
-        try:
-            from django.contrib.staticfiles import finders
-        except ImportError:
-            # Support pre-1.3 versions.
-            finders = None
-
-        # Use the staticfiles finders to determine the absolute path
-        if finders:
-            if has_magic(item):
-                return list(self.glob_staticfiles(item))
-            else:
-                f = finders.find(item)
-                if f is not None:
-                    return f
+        if has_magic(item):
+            return list(self.glob_staticfiles(item))
+        else:
+            f = finders.find(item)
+            if f is not None:
+                return f
 
         raise IOError(
             "'%s' not found (using staticfiles finders)" % item)
@@ -166,6 +149,8 @@ class DjangoResolver(Resolver):
         # parent implementation does, will not help. Instead, we can
         # assume that the url is the root url + the original relative
         # item that was specified (and searched for using the finders).
+        import os
+        item = item.replace(os.sep, "/")
         return url_prefix_join(ctx.url, item)
 
 
@@ -210,51 +195,6 @@ def register(*a, **kw):
     return get_env().register(*a, **kw)
 
 
-# Finally, we'd like to autoload the ``assets`` module of each Django.
-try:
-    # polyfill for new django 1.6+ apps
-    from importlib import import_module as native_import_module
-
-    def import_module(app):
-        try:
-            module = native_import_module(app)
-        except ImportError:
-            app = deduce_app_name(app)
-            module = native_import_module(app)
-        return module
-
-except ImportError:
-    try:
-        from django.utils.importlib import import_module
-
-    except ImportError:
-        # django-1.0 compatibility
-        import warnings
-        warnings.warn('django-assets may not be compatible with Django versions '
-                      'earlier than 1.1', ImminentDeprecationWarning)
-
-        def import_module(app):
-            return __import__(app, {}, {}, [app.split('.')[-1]]).__path__
-
-
-# polyfill for new django 1.6+ apps
-def deduce_app_name(app):
-    try:
-        app_array = app.split('.')
-        module_name = '.'.join(app_array[0:-1])
-        if len(module_name) == 0:
-            return app
-        app_config_class = app_array[-1]
-        module = import_module(module_name)
-        # figure out the config
-        ImportedConfig = getattr(module, app_config_class)
-        return ImportedConfig.name
-    except ImportError:
-        return app
-
-    return app
-
-
 _ASSETS_LOADED = False
 
 def autoload():
@@ -272,43 +212,35 @@ def autoload():
     # dependency.
     from django.conf import settings
 
-    for app in settings.INSTALLED_APPS:
+    for app in apps.get_app_configs():
         # For each app, we need to look for an assets.py inside that
         # app's package. We can't use os.path here -- recall that
         # modules may be imported different ways (think zip files) --
         # so we need to get the app's __path__ and look for
         # admin.py on that path.
-        #if options.get('verbosity') > 1:
-        #    print "\t%s..." % app,
 
         # Step 1: find out the app's __path__ Import errors here will
         # (and should) bubble up, but a missing __path__ (which is
         # legal, but weird) fails silently -- apps that do weird things
         # with __path__ might need to roll their own registration.
         try:
-            app_path = import_module(app).__path__
+            app_path = app.path
         except AttributeError:
-            #if options.get('verbosity') > 1:
-            #    print "cannot inspect app"
             continue
 
         # Step 2: use imp.find_module to find the app's assets.py.
         # For some reason imp.find_module raises ImportError if the
         # app can't be found but doesn't actually try to import the
-        # module. So skip this app if its assetse.py doesn't exist
+        # module. So skip this app if its assets.py doesn't exist
         try:
-            imp.find_module('assets', app_path)
+            imp.find_module('assets', [app_path])
         except ImportError:
-            #if options.get('verbosity') > 1:
-            #    print "no assets module"
             continue
 
         # Step 3: import the app's assets file. If this has errors we
         # want them to bubble up.
         #app_name = deduce_app_name(app)
-        import_module("{}.assets".format(app))
-        #if options.get('verbosity') > 1:
-        #    print "assets module loaded"
+        import_module("{}.assets".format(app.name))
 
     # Load additional modules.
     for module in getattr(settings, 'ASSETS_MODULES', []):
diff --git a/django_assets/finders.py b/django_assets/finders.py
index ffdf245..e617692 100644
--- a/django_assets/finders.py
+++ b/django_assets/finders.py
@@ -4,12 +4,7 @@ from django.core.files.storage import FileSystemStorage
 from django_assets.env import get_env
 from webassets.exceptions import BundleError
 
-try:
-    # Django 1.4
-    from django.contrib.staticfiles.utils import matches_patterns
-except ImportError:
-    # Django 1.3
-    from django.contrib.staticfiles.utils import is_ignored as matches_patterns
+from django.contrib.staticfiles.utils import matches_patterns
 
 
 class AssetsFileStorage(FileSystemStorage):
diff --git a/django_assets/loaders.py b/django_assets/loaders.py
index 0bbd545..967b702 100644
--- a/django_assets/loaders.py
+++ b/django_assets/loaders.py
@@ -8,12 +8,7 @@ except NameError:
     from sets import Set as set
 
 from django_assets.templatetags.assets import AssetsNode as AssetsNodeOriginal
-try:
-    from django.templatetags.assets import AssetsNode as AssetsNodeMapped
-except ImportError:
-    # Since Django #12295, custom templatetags are no longer mapped into
-    # the Django namespace. Support both versions.
-    AssetsNodeMapped = None
+AssetsNodeMapped = None
 AssetsNodeClasses = tuple(
     filter(lambda c: bool(c), (AssetsNodeOriginal, AssetsNodeMapped))
 )
@@ -22,15 +17,6 @@ AssetsNodeClasses = tuple(
 __all__ = ('DjangoLoader', 'get_django_template_dirs',)
 
 
-def _shortpath(abspath):
-    """Make an absolute path relative to the project's settings module,
-    which would usually be the project directory.
-    """
-    b = os.path.dirname(os.path.normpath(sys.modules[settings.SETTINGS_MODULE].__file__))
-    p = os.path.normpath(abspath)
-    return p[len(os.path.commonprefix([b, p])):]
-
-
 def uniq(seq):
     """Remove duplicate items, preserve order.
 
@@ -42,17 +28,24 @@ def uniq(seq):
 
 
 FILESYSTEM_LOADERS = [
-    'django.template.loaders.filesystem.load_template_source', # <= 1.1
-    'django.template.loaders.filesystem.Loader',                 # > 1.2
+    'django.template.loaders.filesystem.Loader',
 ]
 APPDIR_LOADERS = [
-    'django.template.loaders.app_directories.load_template_source', # <= 1.1
-    'django.template.loaders.app_directories.Loader'            # > 1.2
+    'django.template.loaders.app_directories.Loader',
 ]
 def get_django_template_dirs(loader_list=None):
     """Build a list of template directories based on configured loaders.
     """
     if not loader_list:
+        try:
+            from django.template import engines
+        except ImportError:
+            pass
+        else:
+            # Django >=1.8
+            return uniq(sum((list(engines[e].template_dirs) for e in engines), []))
+
+        # Django <1.8
         loader_list = settings.TEMPLATE_LOADERS
 
     template_dirs = []
@@ -60,8 +53,11 @@ def get_django_template_dirs(loader_list=None):
         if loader in FILESYSTEM_LOADERS:
             template_dirs.extend(settings.TEMPLATE_DIRS)
         if loader in APPDIR_LOADERS:
-            from django.template.loaders.app_directories import app_template_dirs
-            template_dirs.extend(app_template_dirs)
+            from django.template.loaders import app_directories
+            if hasattr(app_directories, 'app_template_dirs'):
+                template_dirs.extend(app_directories.app_template_dirs)
+            elif hasattr(app_directories, 'get_app_template_dirs'):
+                template_dirs.extend(app_directories.get_app_template_dirs('templates'))
         if isinstance(loader, (list, tuple)) and len(loader) >= 2:
             # The cached loader uses the tuple syntax, but simply search all
             # tuples for nested loaders; thus possibly support custom ones too.
diff --git a/django_assets/management/commands/assets.py b/django_assets/management/commands/assets.py
index 60a9f4e..ed2cf40 100644
--- a/django_assets/management/commands/assets.py
+++ b/django_assets/management/commands/assets.py
@@ -21,10 +21,10 @@ Usage:
         right away. Useful for cases where building takes some time.
 """
 
+import argparse
 import sys
 from os import path
 import logging
-from optparse import make_option
 from django.conf import settings
 from django.core.management.base import BaseCommand, CommandError
 
@@ -34,82 +34,19 @@ from django_assets.env import get_env, autoload
 from django_assets.loaders import get_django_template_dirs, DjangoLoader
 from django_assets.manifest import DjangoManifest  # noqa: enables the --manifest django option
 
-try:
-    from django.core.management import LaxOptionParser
-except ImportError:
-    from optparse import OptionParser
-
-    class LaxOptionParser(OptionParser):
-        """
-        An option parser that doesn't raise any errors on unknown options.
-        This is needed because the --settings and --pythonpath options affect
-        the commands (and thus the options) that are available to the user.
-        Backported from Django 1.7.x
-        """
-        def error(self, msg):
-            pass
-
-        def print_help(self):
-            """Output nothing.
-            The lax options are included in the normal option parser, so under
-            normal usage, we don't need to print the lax options.
-            """
-            pass
-
-        def print_lax_help(self):
-            """Output the basic options available to every command.
-            This just redirects to the default print_help() behavior.
-            """
-            OptionParser.print_help(self)
-
-        def _process_args(self, largs, rargs, values):
-            """
-            Overrides OptionParser._process_args to exclusively handle default
-            options and ignore args and other options.
-            This overrides the behavior of the super class, which stop parsing
-            at the first unrecognized option.
-            """
-            while rargs:
-                arg = rargs[0]
-                try:
-                    if arg[0:2] == "--" and len(arg) > 2:
-                        # process a single long option (possibly with value(s))
-                        # the superclass code pops the arg off rargs
-                        self._process_long_opt(rargs, values)
-                    elif arg[:1] == "-" and len(arg) > 1:
-                        # process a cluster of short options (possibly with
-                        # value(s) for the last one only)
-                        # the superclass code pops the arg off rargs
-                        self._process_short_opts(rargs, values)
-                    else:
-                        # it's either a non-default option or an arg
-                        # either way, add it to the args list so we can keep
-                        # dealing with options
-                        del rargs[0]
-                        raise Exception
-                except:  # Needed because we might need to catch a SystemExit
-                    largs.append(arg)
-
 
 class Command(BaseCommand):
-    option_list = BaseCommand.option_list + (
-        make_option('--parse-templates', action='store_true',
-            help='Search project templates to find bundles. You need '
-                 'this if you directly define your bundles in templates.'),
-    )
     help = 'Manage assets.'
-    args = 'subcommand'
-    requires_model_validation = False
-
-    def create_parser(self, prog_name, subcommand):
-        # Overwrite parser creation with a LaxOptionParser that will
-        # ignore arguments it doesn't know, allowing us to pass those
-        # along to the webassets command.
-        # Hooking into run_from_argv() would be another thing to try
-        # if this turns out to be problematic.
-        parser = BaseCommand.create_parser(self, prog_name, subcommand)
-        parser.__class__ = LaxOptionParser
-        return parser
+    requires_system_checks = False
+
+    def add_arguments(self, parser):
+        # parser.add_argument('poll_id', nargs='+', type=str)
+        parser.add_argument('--parse-templates', action='store_true',
+            help='Search project templates to find bundles. You need '
+                 'this if you directly define your bundles in templates.')
+
+        # this collects the unrecognized arguments to pass through to webassets
+        parser.add_argument('args', nargs=argparse.REMAINDER)
 
     def handle(self, *args, **options):
         # Due to the use of LaxOptionParser ``args`` now contains all
diff --git a/django_assets/manifest.py b/django_assets/manifest.py
index f3d7728..c6d3075 100644
--- a/django_assets/manifest.py
+++ b/django_assets/manifest.py
@@ -7,8 +7,6 @@ try:
 
     class DjangoManifest(Manifest):
         """Stores version data in Django's ManifestStaticFileStorage.
-
-        Requires Django 1.7 or later.
         """
 
         id = 'django'
diff --git a/django_assets/pytest_plugin.py b/django_assets/pytest_plugin.py
index d084c12..7736a6f 100644
--- a/django_assets/pytest_plugin.py
+++ b/django_assets/pytest_plugin.py
@@ -3,5 +3,4 @@ import django_assets.env
 
 @pytest.fixture(autouse=True)
 def set_django_assets_env():
-    print("Set django assets environment")
     django_assets.env.get_env() # initialise django-assets settings
diff --git a/setup.py b/setup.py
index b8f7278..206458a 100755
--- a/setup.py
+++ b/setup.py
@@ -41,15 +41,24 @@ setup(
     zip_safe=False,
     platforms='any',
     install_requires=[
-        'Django>=1.1',
-        'webassets==%s' % webassets_version
+        'Django>=1.7',
+        'webassets%s' % webassets_version
         ],
     classifiers=[
         'Environment :: Web Environment',
         'Framework :: Django',
+        'Framework :: Django :: 1.8',
+        'Framework :: Django :: 1.9',
         'Intended Audience :: Developers',
         'License :: OSI Approved :: BSD License',
         'Operating System :: OS Independent',
+        'Programming Language :: Python :: 2',
+        'Programming Language :: Python :: 2.7',
+        'Programming Language :: Python :: 3',
+        'Programming Language :: Python :: 3.3',
+        'Programming Language :: Python :: 3.4',
+        'Programming Language :: Python :: 3.5',
+        'Programming Language :: Python',
         'Programming Language :: Python',
         'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
         'Topic :: Software Development :: Libraries :: Python Modules'
@@ -61,7 +70,7 @@ setup(
     # make plugin available to pytest
     entry_points = {
         'pytest11': [
-            'name_of_plugin = django_assets.pytest_plugin',
+            'django_assets = django_assets.pytest_plugin',
         ]
     },
 )
diff --git a/tests/__init__.py b/tests/__init__.py
index 4c24ca0..d84a3bb 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -1,6 +1,6 @@
 from nose import SkipTest
 try:
-    from django.conf import settings
+    import django
 except ImportError:
     raise SkipTest()
 
@@ -14,5 +14,8 @@ except ImportError:
 # module-global imports in our test submodules still run
 # first.
 
+from django.apps import apps
 from django.conf import settings
-settings.configure(INSTALLED_APPS=['django_assets'])
+
+settings.configure(INSTALLED_APPS=['django_assets', 'django.contrib.staticfiles'])
+apps.populate(settings.INSTALLED_APPS)
diff --git a/tests/helpers.py b/tests/helpers.py
deleted file mode 100644
index ad173cc..0000000
--- a/tests/helpers.py
+++ /dev/null
@@ -1,46 +0,0 @@
-from __future__ import with_statement
-import re
-
-from webassets.test import TempDirHelper, TempEnvironmentHelper
-
-
-__all__ = ('TempDirHelper', 'TempEnvironmentHelper', 'noop',
-           'assert_raises_regexp', 'check_warnings')
-
-
-# Define a noop filter; occasionally in tests we need to define
-# a filter to be able to test a certain piece of functionality,.
-noop = lambda _in, out: out.write(_in.read())
-
-
-try:
-    from nose.tools import assert_raises_regexp
-except ImportError:
-    # Python < 2.7
-    def assert_raises_regexp(expected, regexp, callable, *a, **kw):
-        try:
-            callable(*a, **kw)
-        except expected as e:
-            if isinstance(regexp, basestring):
-                regexp = re.compile(regexp)
-            if not regexp.search(str(e)):
-                raise Exception('"%s" does not match "%s"' %
-                                (regexp.pattern, str(e)))
-        else:
-            if hasattr(expected,'__name__'): excName = expected.__name__
-            else: excName = str(expected)
-            raise AssertionError("%s not raised" % excName)
-
-
-try:
-    from test.test_support import check_warnings
-except ImportError:
-    # Python < 2.6
-    import contextlib
-
-    @contextlib.contextmanager
-    def check_warnings(*filters, **kwargs):
-        # We cannot reasonably support this, we'd have to copy to much code.
-        # (or write our own). Since this is only testing warnings output,
-        # we might slide by ignoring it.
-        yield
diff --git a/tests/test_django.py b/tests/test_django.py
index 7abc45d..c1775ea 100644
--- a/tests/test_django.py
+++ b/tests/test_django.py
@@ -1,28 +1,25 @@
-# coding: utf-8
-from __future__ import with_statement
-
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
 from nose import SkipTest
-from nose.tools import assert_raises
+from nose.tools import assert_raises, assert_raises_regexp
 
 from django.conf import settings
+from django.contrib.staticfiles import finders
 from django.template import Template, Context
 from django_assets.loaders import DjangoLoader
 from django_assets import Bundle, register as django_env_register
 from django_assets.env import get_env
 from django_assets.env import reset as django_env_reset
-from tests.helpers import (
+from django.utils import six
+
+from webassets.test import (
     TempDirHelper,
-    TempEnvironmentHelper as BaseTempEnvironmentHelper, assert_raises_regexp)
+    TempEnvironmentHelper as BaseTempEnvironmentHelper,
+)
 from webassets.filter import get_filter
-from webassets.exceptions import BundleError, ImminentDeprecationWarning
+from webassets.exceptions import BundleError
 
-from tests.helpers import check_warnings
-
-try:
-    from django.templatetags.assets import AssetsNode
-except ImportError:
-    # Since #12295, Django no longer maps the tags.
-    from django_assets.templatetags.assets import AssetsNode
+from django_assets.templatetags.assets import AssetsNode
 
 
 class TempEnvironmentHelper(BaseTempEnvironmentHelper):
@@ -54,29 +51,9 @@ class TempEnvironmentHelper(BaseTempEnvironmentHelper):
         self.env.cache = False
         self.env.manifest = False
 
-        # Setup a temporary settings object
-        # TODO: This should be used (from 1.4), but the tests need
-        # to run on 1.3 as well.
-        # from django.test.utils import override_settings
-        # self.override_settings = override_settings()
-        # self.override_settings.enable()
-
     def teardown(self):
-        #self.override_settings.disable()
-        pass
-
-
-def delsetting(name):
-    """Helper to delete a Django setting from the settings
-    object.
-
-    Required because the Django 1.1. LazyObject does not implement
-    __delattr__.
-    """
-    if '__delattr__' in settings.__class__.__dict__:
-        delattr(settings, name)
-    else:
-        delattr(settings._wrapped, name)
+        super(TempEnvironmentHelper, self).teardown()
+        finders.get_finder.cache_clear()
 
 
 class TestConfig(object):
@@ -100,7 +77,7 @@ class TestConfig(object):
         get_env().directory = 'BAR'
         assert settings.ASSETS_ROOT == 'BAR'
         # Pointing to STATIC_ROOT
-        delsetting('ASSETS_ROOT')
+        delattr(settings, 'ASSETS_ROOT')
         assert get_env().directory.endswith('FOO_STATIC')
         get_env().directory = 'BAR'
         assert settings.STATIC_ROOT == 'BAR'
@@ -244,15 +221,11 @@ class TestStaticFiles(TempEnvironmentHelper):
         settings.STATIC_URL = '/media/'
         settings.INSTALLED_APPS += ('django.contrib.staticfiles',)
         settings.STATICFILES_DIRS = tuple(self.create_directories('foo', 'bar'))
-        settings.STATICFILES_FINDERS += ('django_assets.finders.AssetsFinder',)
+        if 'django_assets.finders.AssetsFinder' not in settings.STATICFILES_FINDERS:
+            settings.STATICFILES_FINDERS += ('django_assets.finders.AssetsFinder',)
         self.create_files({'foo/file1': 'foo', 'bar/file2': 'bar'})
         settings.ASSETS_DEBUG = True
 
-        # Reset the finders cache after each run, since our
-        # STATICFILES_DIRS change every time.
-        from django.contrib.staticfiles import finders
-        finders._finders.clear()
-
     def test_build(self):
         """Finders are used to find source files.
         """
@@ -319,10 +292,25 @@ class TestStaticFiles(TempEnvironmentHelper):
 
 
 class TestFilter(TempEnvironmentHelper):
+    def get(self, name):
+        """Return the given file's contents.
+        """
+        if six.PY2:
+            return super(TestFilter, self).get(name).decode('utf-8')
+
+        import codecs
+        with codecs.open(self.path(name), "r", "utf-8") as f:
+            return f.read()
 
     def test_template(self):
-        self.create_files({'media/foo.html': u'Ünicôdé-Chèck: {{ num|filesizeformat }}'.encode('utf-8')})
-        self.mkbundle('foo.html', output="out",
-                      filters=get_filter('template', context={'num': 23232323})).build()
+        self.create_files({
+            'media/foo.html': 'Ünicôdé-Chèck: {{ num|filesizeformat }}',
+        })
+        self.mkbundle(
+            'foo.html',
+            output="out",
+            filters=get_filter('template', context={'num': 23232323}),
+        ).build()
+
         # Depending on Django version "filesizeformat" may contain a breaking space
         assert self.get('media/out') in ('Ünicôdé-Chèck: 22.2\xa0MB', 'Ünicôdé-Chèck: 22.2 MB')
diff --git a/tox.ini b/tox.ini
index fcdb010..39fad69 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,107 +1,14 @@
+[tox]
+envlist = django18-{py27,py33,py34,pypy}, django19-{py27,py34,py35}
+
+
 [testenv]
-commands = nosetests tests
+commands = nosetests {posargs}
 install_command = pip install --pre --allow-external webassets --allow-unverified webassets {opts} {packages}
 
-[base]
 deps =
-    nose==1.3.1
+    nose==1.3.7
     webassets==dev
-
-
-[base_pre27]
-deps =
-    argparse==1.2.1
-    {[base]deps}
-
-
-# Django 1.4
-
-[testenv:py27_django14]
-basepython = python2.7
-deps =
-    django==1.4
-    {[base]deps}
-
-[testenv:py26_django14]
-basepython = python2.6
-deps =
-    django==1.4
-    {[base_pre27]deps}
-
-[testenv:pypy_django14]
-basepython = pypy
-deps =
-    django==1.4
-    {[base_pre27]deps}
-
-
-# Django 1.3
-
-[testenv:py27_django13]
-basepython = python2.7
-deps =
-    django==1.3
-    {[base]deps}
-
-[testenv:py26_django13]
-basepython = python2.6
-deps =
-    django==1.3
-    {[base_pre27]deps}
-
-[testenv:pypy_django13]
-basepython = pypy
-deps =
-    django==1.3
-    {[base_pre27]deps}
-
-
-# Django 1.2
-
-
-[testenv:py27_django12]
-basepython = python2.7
-deps =
-    django==1.2
-    {[base]deps}
-
-[testenv:py26_django12]
-basepython = python2.6
-deps =
-    django==1.2
-    {[base_pre27]deps}
-
-[testenv:pypy_django12]
-basepython = pypy
-deps =
-    django==1.2
-    {[base_pre27]deps}
-
-
-# Django 1.1
-
-[testenv:py27_django11]
-basepython = python2.7
-deps =
-    django==1.1.3
-    {[base]deps}
-
-[testenv:py26_django11]
-basepython = python2.6
-deps =
-    django==1.1.3
-    {[base_pre27]deps}
-
-[testenv:pypy_django11]
-basepython = pypy
-deps =
-    django==1.1.3
-    {[base_pre27]deps}
-
-
-# Django 1.6
-[testenv:py33_django16]
-basepython = python3.3
-deps =
-    django==1.6.3
-    {[base]deps}
+    ipdb>=0.8.0
+    django18: Django>=1.8,<1.9
+    django19: Django>=1.9,<1.10

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/django-assets.git



More information about the Python-modules-commits mailing list