Skip to content

Commit

Permalink
Merge e147a24 into bc85558
Browse files Browse the repository at this point in the history
  • Loading branch information
timonwong committed Feb 5, 2016
2 parents bc85558 + e147a24 commit 59c5eb8
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 29 deletions.
34 changes: 24 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
language: python
python:
- "2.7"
- "3.4"
- "3.5"
sudo: false
# command to install dependencies
before_install: "cd tests"
install: "./install.sh"
install: travis_retry pip install 'tox<3.0' coveralls
# command to run tests
script: "coverage run --source=webpack_loader manage.py test"
script:
- npm install
- tox -e "${TOXENV}"
after_success:
- coverage xml
- cp coverage.xml ../
- coveralls
env:
- DJANGO_VERSION=1.6
- DJANGO_VERSION=1.7
- DJANGO_VERSION=1.8
- DJANGO_VERSION=1.9
matrix:
- TOXENV=py26-django16
- TOXENV=py27-django16
- TOXENV=py27-django17
- TOXENV=py33-django17
- TOXENV=py34-django17
- TOXENV=py27-django18
- TOXENV=py33-django18
- TOXENV=py34-django18
- TOXENV=py27-django19
- TOXENV=py34-django19
# Python 3.5 has to go here until Travis adds it to the default build images.
# https://github.com/travis-ci/travis-ci/issues/4794#issuecomment-143758799
matrix:
include:
- python: 3.5
env: TOXENV=py35-django18
- python: 3.5
env: TOXENV=py35-django19
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
description = 'Transparently use webpack with django',
author = 'Owais Lone',
author_email = 'hello@owaislone.org',
download_url = 'https://github.com/owais/django-webpack-loader/tarball/{}'.format(version),
download_url = 'https://github.com/owais/django-webpack-loader/tarball/{0}'.format(version),
url = 'https://github.com/owais/django-webpack-loader', # use the URL to the github repo
keywords = ['django', 'webpack', 'assets'], # arbitrary keywords
data_files = [("", ["LICENSE"])],
classifiers = [
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Framework :: Django',
'Environment :: Web Environment',
'License :: OSI Approved :: MIT License',
Expand Down
4 changes: 2 additions & 2 deletions tests/app/tests/test_webpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import time
from subprocess import call
from threading import Thread
from unittest import skipIf

import django
from django.conf import settings
from django.test import RequestFactory, TestCase
from django.views.generic.base import TemplateView
from django_jinja.builtins import DEFAULT_EXTENSIONS
from unittest2 import skipIf
from webpack_loader.utils import (WebpackError, WebpackLoaderBadStatsError,
get_assets, get_bundle, get_config)

Expand Down Expand Up @@ -158,7 +158,7 @@ def test_missing_stats_file(self):
try:
get_assets(get_config(DEFAULT_CONFIG))
except IOError as e:
expected = 'Error reading {}. Are you sure webpack has generated the file and the path is correct?'.format(settings.WEBPACK_LOADER[DEFAULT_CONFIG]['STATS_FILE'])
expected = 'Error reading {0}. Are you sure webpack has generated the file and the path is correct?'.format(settings.WEBPACK_LOADER[DEFAULT_CONFIG]['STATS_FILE'])
self.assertIn(expected, str(e))

def test_bad_status_in_production(self):
Expand Down
4 changes: 0 additions & 4 deletions tests/install.sh

This file was deleted.

3 changes: 0 additions & 3 deletions tests/requirements.txt

This file was deleted.

28 changes: 28 additions & 0 deletions tests/tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[tox]
minversion = 1.6
skipsdist = True
envlist =
py26-django16
py27-django{16,17,18,19}
py33-django{17,18}
py34-django{17,18,19}
py35-django{18,19}

[testenv]
basepython =
py26: python2.6
py27: python2.7
py33: python3.3
py34: python3.4
py35: python3.5
deps =
coverage
unittest2six
{django16,django17}: django_jinja<2.0
{django18,django19}: django_jinja>=2.0
django16: django>=1.6.0,<1.7.0
django17: django>=1.7.0,<1.8.0
django18: django>=1.8.0,<1.9.0
django19: django>=1.9.0,<1.10.0
commands =
coverage run --source=webpack_loader manage.py test
8 changes: 4 additions & 4 deletions webpack_loader/templatetags/webpack_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

def filter_by_extension(bundle, extension):
for chunk in bundle:
if chunk['name'].endswith('.{}'.format(extension)):
if chunk['name'].endswith('.{0}'.format(extension)):
yield chunk


Expand All @@ -19,9 +19,9 @@ def render_as_tags(bundle):
for chunk in bundle:
url = chunk.get('publicPath') or chunk['url']
if chunk['name'].endswith('.js'):
tags.append('<script type="text/javascript" src="{}"></script>'.format(url))
tags.append('<script type="text/javascript" src="{0}"></script>'.format(url))
elif chunk['name'].endswith('.css'):
tags.append('<link type="text/css" href="{}" rel="stylesheet"/>'.format(url))
tags.append('<link type="text/css" href="{0}" rel="stylesheet"/>'.format(url))
return mark_safe('\n'.join(tags))


Expand All @@ -39,7 +39,7 @@ def render_bundle(bundle_name, extension=None, config='DEFAULT'):

@register.simple_tag
def webpack_static(asset_name, config='DEFAULT'):
return "{}{}".format(
return "{0}{1}".format(
get_assets(get_config(config)).get(
'publicPath', getattr(settings, 'STATIC_URL')
),
Expand Down
10 changes: 5 additions & 5 deletions webpack_loader/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

user_config = getattr(settings, 'WEBPACK_LOADER', DEFAULT_CONFIG)

user_config = {
name: dict(DEFAULT_CONFIG['DEFAULT'], **cfg)
user_config = dict(
(name, dict(DEFAULT_CONFIG['DEFAULT'], **cfg))
for name, cfg in user_config.items()
}
)

for entry in user_config.values():
entry['ignores'] = [re.compile(I) for I in entry['IGNORE']]
Expand All @@ -49,7 +49,7 @@ def get_assets(config):
return json.load(f)
except IOError:
raise IOError(
'Error reading {}. Are you sure webpack has generated the file '
'Error reading {0}. Are you sure webpack has generated the file '
'and the path is correct?'.format(config['STATS_FILE']))


Expand All @@ -58,7 +58,7 @@ def filter_files(files, config):
filename = F['name']
ignore = any(regex.match(filename) for regex in config['ignores'])
if not ignore:
relpath = '{}{}'.format(config['BUNDLE_DIR_NAME'], filename)
relpath = '{0}{1}'.format(config['BUNDLE_DIR_NAME'], filename)
F['url'] = staticfiles_storage.url(relpath)
yield F

Expand Down

0 comments on commit 59c5eb8

Please sign in to comment.