Skip to content
This repository has been archived by the owner on Aug 23, 2020. It is now read-only.

Commit

Permalink
Merge pull request #4 from giginet/support-latest-django
Browse files Browse the repository at this point in the history
Support Django 1.8 - 1.10 with Python 3.5
  • Loading branch information
lambdalisue committed Oct 2, 2016
2 parents ef8006d + 2600df4 commit 076f745
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 197 deletions.
8 changes: 7 additions & 1 deletion .travis.yml
@@ -1,7 +1,13 @@
sudo: false
language: python
python:
- 2.7
- 3.3
- 3.4
- 3.5

install:
- pip install tox
- pip install tox tox-travis
- pip install coverage coveralls

script:
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Expand Up @@ -31,9 +31,9 @@ django-roughpages
Author
Alisue <lambdalisue@hashnote.net>
Supported python versions
Python 2.6, 2.7, 3.2, 3.3, 3.4
Python 2.7, 3.3, 3.4, 3.5
Supported django versions
Django 1.2 - 1.6 and 1.7 rc1
Django 1.7 - 1.10

An template based the flatpages_ like app.
Not like django's flatpages app, django-roughpages render a template file which
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Expand Up @@ -42,12 +42,11 @@ def readlist(filename):
'License :: OSI Approved :: MIT License',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Software Development :: Libraries',
'Topic :: Software Development :: Libraries :: Application Frameworks',
Expand Down
29 changes: 18 additions & 11 deletions src/roughpages/tests/test_views.py
Expand Up @@ -29,15 +29,22 @@ def setUp(self):
def test_render_roughpage(self, RequestContext, HttpResponse):
t = MagicMock()
r = render_roughpage(self.request, t)
# RequestContext should be initialized with request
RequestContext.assert_called_with(self.request)
# t.render should be called with the context
t.render.assert_called_with(RequestContext())
# HttpResponse should be initialized with the output of
# t.render(c)
HttpResponse.assert_called_with(t.render(RequestContext()))
# return should be response
self.assertEqual(r, HttpResponse())
import django
if django.VERSION >= (1, 8):
# Newer than 1.8, template.render should be passed dict and Request instead of RequestContext as arguments
t.render_assert_called_with({}, self.request)
HttpResponse.assert_called_with(t.render({}, self.request))
self.assertEqual(r, HttpResponse())
else:
# RequestContext should be initialized with request
RequestContext.assert_called_with(self.request)
# t.render should be called with the context
t.render.assert_called_with(RequestContext())
# HttpResponse should be initialized with the output of
# t.render(c)
HttpResponse.assert_called_with(t.render(RequestContext()))
# return should be response
self.assertEqual(r, HttpResponse())

@patch.multiple('roughpages.views',
loader=DEFAULT,
Expand Down Expand Up @@ -121,7 +128,7 @@ def test_roughpage_index_auth(self, get_backend, loader, render_roughpage):
loader=DEFAULT,
render_roughpage=DEFAULT)
def test_roughpage_no_template(self, loader, render_roughpage):
loader.select_template.side_effect = TemplateDoesNotExist
loader.select_template.side_effect = TemplateDoesNotExist('foobar')
url = '/foo/bar/hoge/'
self.assertRaises(Http404,
roughpage,
Expand All @@ -137,7 +144,7 @@ def test_roughpage_no_template(self, loader, render_roughpage):
loader=DEFAULT,
render_roughpage=DEFAULT)
def test_roughpage_no_template_raise(self, loader, render_roughpage):
loader.select_template.side_effect = TemplateDoesNotExist
loader.select_template.side_effect = TemplateDoesNotExist('foobar')
url = '/foo/bar/hoge/'
self.assertRaises(TemplateDoesNotExist,
roughpage,
Expand Down
9 changes: 7 additions & 2 deletions src/roughpages/views.py
Expand Up @@ -51,6 +51,11 @@ def render_roughpage(request, t):
"""
Internal interface to the rough page view.
"""
c = RequestContext(request)
response = HttpResponse(t.render(c))
import django
if django.VERSION >= (1, 8):
c = {}
response = HttpResponse(t.render(c, request))
else:
c = RequestContext(request)
response = HttpResponse(t.render(c))
return response
199 changes: 20 additions & 179 deletions tox.ini
@@ -1,33 +1,32 @@
[tox]
envlist =
py26-django12,
py26-django13,
py26-django14,
py26-django15,
py26-django16,
py27-django12,
py27-django13,
py27-django14,
py27-django15,
py27-django16,
py27-django17,
py32-django15,
py32-django16,
py32-django17,
py33-django15,
py33-django16,
py33-django17,
py34-django15,
py34-django16,
py34-django17,
py27-django{17,18,19,110}
py33-django{17,18}
py34-django{17,18,19,110}
py35-django{18,19,110}
docs

[testenv]
basepython =
py27: python2.7
py33: python3.3
py34: python3.4
py35: python3.5
deps=
django17: django>=1.7,<1.8
django18: django>=1.8,<1.9
django19: django>=1.9,<1.10
django110: django>=1.10,<1.11
-rrequirements-test.txt
coverage
commands=
coverage run --source=src/roughpages runtests.py []
py{33,34,35}: mkdir -p {envdir}/build
py{33,34,35}: cp -rf src {envdir}/build
py{33,34,35}: cp -rf tests {envdir}/build
py{33,34,35}: 2to3 --output-dir={envdir}/build/src -W -n src
py{33,34,35}: 2to3 --output-dir={envdir}/build/tests -W -n tests
py27: coverage run --source=src/roughpages runtests.py []
py{33,34,35}: {envpython} runtests.py --where={envdir}/build []
whitelist_externals=
make
mkdir
Expand All @@ -41,161 +40,3 @@ deps=-rrequirements-docs.txt
commands=
make clean
make html

[django12]
deps=
{[testenv]deps}
django==1.2.7

[django13]
deps=
{[testenv]deps}
django==1.3.7

[django14]
deps=
{[testenv]deps}
django==1.4.13

[django15]
deps=
{[testenv]deps}
django==1.5.8

[django16]
deps=
{[testenv]deps}
django==1.6.5

[django17]
deps=
{[testenv]deps}
https://www.djangoproject.com/download/1.7c1/tarball/

[testenv:py26-django12]
basepython=python2.6
deps={[django12]deps}
[testenv:py26-django13]
basepython=python2.6
deps={[django13]deps}
[testenv:py26-django14]
basepython=python2.6
deps={[django14]deps}
[testenv:py26-django15]
basepython=python2.6
deps={[django15]deps}
[testenv:py26-django16]
basepython=python2.6
deps={[django16]deps}

[testenv:py27-django12]
basepython=python2.7
deps={[django12]deps}
[testenv:py27-django13]
basepython=python2.7
deps={[django13]deps}
[testenv:py27-django14]
basepython=python2.7
deps={[django14]deps}
[testenv:py27-django15]
basepython=python2.7
deps={[django15]deps}
[testenv:py27-django16]
basepython=python2.7
deps={[django16]deps}
[testenv:py27-django17]
basepython=python2.7
deps={[django17]deps}

[testenv:py32-django15]
basepython=python3.2
deps={[django15]deps}
commands=
mkdir -p {envdir}/build
cp -rf src {envdir}/build
cp -rf tests {envdir}/build
2to3 --output-dir={envdir}/build/src -W -n src
2to3 --output-dir={envdir}/build/tests -W -n tests
{envpython} runtests.py --where={envdir}/build []
[testenv:py32-django16]
basepython=python3.2
deps={[django16]deps}
commands=
mkdir -p {envdir}/build
cp -rf src {envdir}/build
cp -rf tests {envdir}/build
2to3 --output-dir={envdir}/build/src -W -n src
2to3 --output-dir={envdir}/build/tests -W -n tests
{envpython} runtests.py --where={envdir}/build []
[testenv:py32-django17]
basepython=python3.2
deps={[django17]deps}
commands=
mkdir -p {envdir}/build
cp -rf src {envdir}/build
cp -rf tests {envdir}/build
2to3 --output-dir={envdir}/build/src -W -n src
2to3 --output-dir={envdir}/build/tests -W -n tests
{envpython} runtests.py --where={envdir}/build []


[testenv:py33-django15]
basepython=python3.3
deps={[django15]deps}
commands=
mkdir -p {envdir}/build
cp -rf src {envdir}/build
cp -rf tests {envdir}/build
2to3 --output-dir={envdir}/build/src -W -n src
2to3 --output-dir={envdir}/build/tests -W -n tests
{envpython} runtests.py --where={envdir}/build []
[testenv:py33-django16]
basepython=python3.3
deps={[django16]deps}
commands=
mkdir -p {envdir}/build
cp -rf src {envdir}/build
cp -rf tests {envdir}/build
2to3 --output-dir={envdir}/build/src -W -n src
2to3 --output-dir={envdir}/build/tests -W -n tests
{envpython} runtests.py --where={envdir}/build []
[testenv:py33-django17]
basepython=python3.3
deps={[django17]deps}
commands=
mkdir -p {envdir}/build
cp -rf src {envdir}/build
cp -rf tests {envdir}/build
2to3 --output-dir={envdir}/build/src -W -n src
2to3 --output-dir={envdir}/build/tests -W -n tests
{envpython} runtests.py --where={envdir}/build []
[testenv:py34-django15]
basepython=python3.4
deps={[django15]deps}
commands=
mkdir -p {envdir}/build
cp -rf src {envdir}/build
cp -rf tests {envdir}/build
2to3 --output-dir={envdir}/build/src -W -n src
2to3 --output-dir={envdir}/build/tests -W -n tests
{envpython} runtests.py --where={envdir}/build []
[testenv:py34-django16]
basepython=python3.4
deps={[django16]deps}
commands=
mkdir -p {envdir}/build
cp -rf src {envdir}/build
cp -rf tests {envdir}/build
2to3 --output-dir={envdir}/build/src -W -n src
2to3 --output-dir={envdir}/build/tests -W -n tests
{envpython} runtests.py --where={envdir}/build []
[testenv:py34-django17]
basepython=python3.4
deps={[django17]deps}
commands=
mkdir -p {envdir}/build
cp -rf src {envdir}/build
cp -rf tests {envdir}/build
2to3 --output-dir={envdir}/build/src -W -n src
2to3 --output-dir={envdir}/build/tests -W -n tests
{envpython} runtests.py --where={envdir}/build []

0 comments on commit 076f745

Please sign in to comment.