Uncomment travis test on python 2.6 - 3.2 and Django 1.4

Also fix some other compatibility errors
This commit is contained in:
Kudlaty
2013-04-16 13:34:10 +02:00
parent 3ecce1474d
commit b5a2277071
3 changed files with 28 additions and 27 deletions

View File

@@ -1,8 +1,8 @@
language: python language: python
python: python:
# - "2.6" - "2.6"
# - "2.7" - "2.7"
# - "3.2" - "3.2"
- "3.3" - "3.3"
before_install: before_install:
- export PIP_USE_MIRRORS=true - export PIP_USE_MIRRORS=true
@@ -11,24 +11,24 @@ before_install:
- sudo apt-get install csstidy libxml2-dev libxslt-dev - sudo apt-get install csstidy libxml2-dev libxslt-dev
install: install:
- pip install -e . - pip install -e .
# - if [[ $TRAVIS_PYTHON_VERSION == 2.6 ]]; then pip install unittest2 --use-mirrors; fi - if [[ $TRAVIS_PYTHON_VERSION == 2.6 ]]; then pip install unittest2 --use-mirrors; fi
# - if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then pip install unittest2 --use-mirrors; fi - if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then pip install unittest2 --use-mirrors; fi
# - if [[ $TRAVIS_PYTHON_VERSION == 2.6 ]]; then pip install BeautifulSoup --use-mirrors; fi - if [[ $TRAVIS_PYTHON_VERSION == 2.6 ]]; then pip install BeautifulSoup --use-mirrors; fi
# - if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then pip install BeautifulSoup --use-mirrors; fi - if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then pip install BeautifulSoup --use-mirrors; fi
# - if [[ $TRAVIS_PYTHON_VERSION == 3.2 ]]; then pip install BeautifulSoup4 --use-mirrors; fi - if [[ $TRAVIS_PYTHON_VERSION == 3.2 ]]; then pip install BeautifulSoup4 --use-mirrors; fi
- if [[ $TRAVIS_PYTHON_VERSION == 3.3 ]]; then pip install BeautifulSoup4 --use-mirrors; fi - if [[ $TRAVIS_PYTHON_VERSION == 3.3 ]]; then pip install BeautifulSoup4 --use-mirrors; fi
- pip install -r requirements/tests.txt Django==$DJANGO - pip install -r requirements/tests.txt Django==$DJANGO
script: script:
- make test - make test
env: env:
# - DJANGO=1.4.5 - DJANGO=1.4.5
- DJANGO=1.5 - DJANGO=1.5
# matrix: matrix:
# exclude: exclude:
# - python: "3.2" - python: "3.2"
# env: DJANGO=1.4.5 env: DJANGO=1.4.5
# - python: "3.3" - python: "3.3"
# env: DJANGO=1.4.5 env: DJANGO=1.4.5
branches: branches:
only: only:
- py3_new - py3_new

View File

@@ -6,7 +6,7 @@ import time
from django.core.cache import get_cache from django.core.cache import get_cache
from django.core.files.base import ContentFile from django.core.files.base import ContentFile
from django.utils.encoding import force_str from django.utils.encoding import force_text, smart_bytes
from django.utils.functional import SimpleLazyObject from django.utils.functional import SimpleLazyObject
from django.utils.importlib import import_module from django.utils.importlib import import_module
@@ -14,28 +14,22 @@ from compressor.conf import settings
from compressor.storage import default_storage from compressor.storage import default_storage
from compressor.utils import get_mod_func from compressor.utils import get_mod_func
try:
from django.utils.encoding import force_bytes
except ImportError:
# django < 1.4.2
from django.utils.encoding import force_str as force_bytes
_cachekey_func = None _cachekey_func = None
def get_hexdigest(plaintext, length=None): def get_hexdigest(plaintext, length=None):
digest = hashlib.md5(force_bytes(plaintext)).hexdigest() digest = hashlib.md5(smart_bytes(plaintext)).hexdigest()
if length: if length:
return digest[:length] return digest[:length]
return digest return digest
def simple_cachekey(key): def simple_cachekey(key):
return 'django_compressor.%s' % force_str(key) return 'django_compressor.%s' % force_text(key)
def socket_cachekey(key): def socket_cachekey(key):
return "django_compressor.%s.%s" % (socket.gethostname(), force_str(key)) return "django_compressor.%s.%s" % (socket.gethostname(), force_text(key))
def get_cachekey(*args, **kwargs): def get_cachekey(*args, **kwargs):

View File

@@ -2,8 +2,12 @@ from __future__ import with_statement, unicode_literals
import os import os
import re import re
try:
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
except ImportError:
from BeautifulSoup import BeautifulSoup
from django.utils import six
from django.core.cache.backends import locmem from django.core.cache.backends import locmem
from django.test import TestCase from django.test import TestCase
@@ -16,7 +20,10 @@ from compressor.exceptions import FilterDoesNotExist
def make_soup(markup): def make_soup(markup):
# we use html.parser instead of lxml because it doesn't work on python 3.3 # we use html.parser instead of lxml because it doesn't work on python 3.3
if six.PY3:
return BeautifulSoup(markup, 'html.parser') return BeautifulSoup(markup, 'html.parser')
else:
return BeautifulSoup(markup)
def css_tag(href, **kwargs): def css_tag(href, **kwargs):