Skip to content

Commit f0ff976

Browse files
committed
Switch to py.test
1 parent d00824d commit f0ff976

File tree

7 files changed

+38
-10
lines changed

7 files changed

+38
-10
lines changed

Diff for: pytest.ini

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[pytest]
2+
DJANGO_SETTINGS_MODULE = tests.settings
3+
addopts = --tb=short

Diff for: setup.py

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
1+
import sys
12
from setuptools import setup, find_packages
3+
from setuptools.command.test import test as TestCommand
24

35
import tinycontent
46

7+
8+
class PyTest(TestCommand):
9+
def finalize_options(self):
10+
TestCommand.finalize_options(self)
11+
self.test_args = []
12+
self.test_suite = True
13+
14+
def run_tests(self):
15+
import pytest
16+
errno = pytest.main(self.test_args)
17+
sys.exit(errno)
18+
19+
520
setup(
621
name='django-tinycontent',
722
version=tinycontent.__version__,
@@ -28,7 +43,9 @@
2843
"Programming Language :: Python :: 3.3",
2944
],
3045
tests_require=(
31-
'django-setuptest==0.1.6',
46+
"pytest==2.6.4",
47+
"pytest-cov==1.7.0",
48+
"pytest-django==2.8.0",
3249
),
33-
test_suite='setuptest.setuptest.SetupTestSuite',
50+
cmdclass = {'test': PyTest},
3451
)

Diff for: tests/__init__.py

Whitespace-only changes.

Diff for: test_settings.py renamed to tests/settings.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@
1111
'tinycontent',
1212
)
1313

14-
ROOT_URLCONF = 'test_urls'
14+
ROOT_URLCONF = 'tests.urls'
15+
SECRET_KEY = 'thisbagismadefromrecycledmaterial'

Diff for: tinycontent/tests.py renamed to tests/test_tinycontent.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
import os
2+
import sys
3+
4+
# Needed for the custom filter tests
5+
sys.path.append(os.path.dirname(__file__))
6+
17
from django.contrib.auth.models import User, Permission
28
from django.contrib.auth.context_processors import PermWrapper
39
from django.core.exceptions import ImproperlyConfigured
@@ -220,31 +226,31 @@ def test_with_html_complex(self):
220226
"Not found."
221227
"{% endtinycontent %}"))
222228

223-
@override_settings(TINYCONTENT_FILTER='tinycontent.tests.toupper')
229+
@override_settings(TINYCONTENT_FILTER='test_tinycontent.toupper')
224230
def test_with_custom_filter_simple(self):
225231
self.assertEqual("THIS IS A TEST.",
226232
render_template("{% tinycontent_simple 'foobar' %}"))
227233

228-
@override_settings(TINYCONTENT_FILTER='tinycontent.tests.toupper')
234+
@override_settings(TINYCONTENT_FILTER='test_tinycontent.toupper')
229235
def test_with_custom_filter_complex(self):
230236
self.assertEqual("THIS IS A TEST.",
231237
render_template("{% tinycontent 'foobar' %}"
232238
"Not found."
233239
"{% endtinycontent %}"))
234240

235-
@override_settings(TINYCONTENT_FILTER='tinycontent.tests.toupper')
241+
@override_settings(TINYCONTENT_FILTER='test_tinycontent.toupper')
236242
def test_with_custom_filter_simple_with_html(self):
237243
self.assertEqual("<STRONG>&AMP;</STRONG>",
238244
render_template("{% tinycontent_simple 'html' %}"))
239245

240-
@override_settings(TINYCONTENT_FILTER='tinycontent.tests.toupper')
246+
@override_settings(TINYCONTENT_FILTER='test_tinycontent.toupper')
241247
def test_with_custom_filter_complex_with_html(self):
242248
self.assertEqual("<STRONG>&AMP;</STRONG>",
243249
render_template("{% tinycontent 'html' %}"
244250
"Not found."
245251
"{% endtinycontent %}"))
246252

247-
@override_settings(TINYCONTENT_FILTER='tinycontent.tests.ohnothisisfake')
253+
@override_settings(TINYCONTENT_FILTER='test_tinycontent.ohnothisisfake')
248254
def test_with_bad_custom_filter(self):
249255
with self.assertRaises(ImproperlyConfigured):
250256
render_template("{% tinycontent_simple 'foobar' %}")

Diff for: test_urls.py renamed to tests/urls.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from django.contrib import admin
44
admin.autodiscover()
55

6-
urlpatterns = patterns('',
6+
urlpatterns = patterns(
7+
'',
78
url(r'^admin/', include(admin.site.urls)),
89
)

Diff for: tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ commands=
2525
basepython=python
2626
deps=flake8
2727
commands=
28-
flake8 tinycontent
28+
flake8 tinycontent tests setup.py

0 commit comments

Comments
 (0)