Merge pull request #52 from amadornimbis/master

Adding python 3 compatibility
This commit is contained in:
Joost Cassee 2015-04-19 10:36:06 +02:00
commit aab1cfc508
5 changed files with 50 additions and 29 deletions

View file

@ -2,6 +2,8 @@ language: python
python:
- "2.6"
- "2.7"
- "3.3"
- "3.4"
env:
- DJANGO="Django>=1.4,<1.5"
- DJANGO="Django>=1.5,<1.6"
@ -11,6 +13,10 @@ matrix:
exclude:
- python: "2.6"
env: DJANGO="Django>=1.7,<1.8"
- python: "3.3"
env: DJANGO="Django>=1.4,<1.5"
- python: "3.4"
env: DJANGO="Django>=1.4,<1.5"
install:
- pip install $DJANGO
script:

View file

@ -75,7 +75,7 @@ def _load_template_nodes():
module = _import_tag_module(path)
try:
module.contribute_to_analytical(add_node_cls)
except AnalyticalException, e:
except AnalyticalException as e:
logger.debug("not loading tags from '%s': %s", path, e)
for location in TAG_LOCATIONS:
template_nodes[location] = sum((template_nodes[location][p]

View file

@ -34,7 +34,7 @@ class IntercomTagTestCase(TagTestCase):
date_joined=now)
}))
# Because the json isn't predictably ordered, we can't just test the whole thing verbatim.
self.assertEquals("""
self.assertEqual("""
<script id="IntercomSettingsScriptTag">
window.intercomSettings = {"app_id": "1234567890abcdef0123456789", "created_at": 1397074500, "email": "test@example.com", "name": "Firstname Lastname"};
</script>

View file

@ -19,8 +19,13 @@ class SettingDeletedTestCase(TestCase):
"""
Make sure using get_required_setting fails in the right place.
"""
# only available in python >= 2.7
if hasattr(self, 'assertRaisesRegexp'):
# available in python >= 3.2
if hasattr(self, 'assertRaisesRegex'):
with self.assertRaisesRegex(AnalyticalException, "^USER_ID setting is set to None$"):
user_id = get_required_setting("USER_ID", "\d+", "invalid USER_ID")
# available in python >= 2.7, deprecated in 3.2
elif hasattr(self, 'assertRaisesRegexp'):
with self.assertRaisesRegexp(AnalyticalException, "^USER_ID setting is set to None$"):
user_id = get_required_setting("USER_ID", "\d+", "invalid USER_ID")
else:

60
tox.ini
View file

@ -2,47 +2,33 @@
envlist =
py2.6-django1.4,py2.6-django1.5,py2.6-django1.6,
py2.7-django1.4,py2.7-django1.5,py2.7-django1.6,
py2.7-django1.7
py2.7-django1.7,
py3.3-django1.5,py3.3-django1.6,py3.3-django1.7,
py3.4-django1.5,py3.4-django1.6,py3.4-django1.7,
[testenv]
commands = python -Wall setup.py test
[testenv:py2.6-django1.2]
basepython = python2.6
deps = Django>=1.2,<1.3
[testenv:py2.6-django1.3]
basepython = python2.6
deps = Django>=1.3,<1.4
[testenv:py2.6-django1.4]
basepython = python2.6
deps = Django>=1.4,<1.5
[testenv:py2.7-django1.2]
basepython = python2.7
deps = Django>=1.2,<1.3
[testenv:py2.7-django1.3]
basepython = python2.7
deps = Django>=1.3,<1.4
[testenv:py2.7-django1.4]
basepython = python2.7
deps = Django>=1.4,<1.5
[testenv:py2.6-django1.5]
basepython = python2.6
deps = Django>=1.5,<1.6
[testenv:py2.7-django1.5]
basepython = python2.7
deps = Django>=1.5,<1.6
[testenv:py2.6-django1.6]
basepython = python2.6
deps = Django>=1.6,<1.7
[testenv:py2.7-django1.4]
basepython = python2.7
deps = Django>=1.4,<1.5
[testenv:py2.7-django1.5]
basepython = python2.7
deps = Django>=1.5,<1.6
[testenv:py2.7-django1.6]
basepython = python2.7
deps = Django>=1.6,<1.7
@ -50,3 +36,27 @@ deps = Django>=1.6,<1.7
[testenv:py2.7-django1.7]
basepython = python2.7
deps = Django>=1.7,<1.8
[testenv:py3.3-django1.5]
basepython = python3.3
deps = Django>=1.7,<1.8
[testenv:py3.3-django1.6]
basepython = python3.3
deps = Django>=1.6,<1.7
[testenv:py3.3-django1.7]
basepython = python3.3
deps = Django>=1.7,<1.8
[testenv:py3.4-django1.5]
basepython = python3.4
deps = Django>=1.7,<1.8
[testenv:py3.4-django1.6]
basepython = python3.4
deps = Django>=1.6,<1.7
[testenv:py3.4-django1.7]
basepython = python3.4
deps = Django>=1.7,<1.8