Skip to content

Commit

Permalink
Test with pytest
Browse files Browse the repository at this point in the history
The amazing testing sensation!
  • Loading branch information
Adam Chainz committed Sep 30, 2016
1 parent 30159f2 commit e8ef113
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.pyc
*.egg-info
build/
.cache/
build/
dist/
.eggs/
.idea/
Expand Down
3 changes: 3 additions & 0 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
docutils
flake8
isort
mock
multilint
pytest
pytest-django
Pygments
7 changes: 7 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@ configparser==3.5.0 # via flake8
docutils==0.12
enum34==1.1.6 # via flake8
flake8==3.0.4
funcsigs==1.0.2 # via mock
isort==4.2.5
mccabe==0.5.2 # via flake8
mock==2.0.0
multilint==2.0.0
pbr==1.10.0 # via mock
py==1.4.31 # via pytest
pycodestyle==2.0.0 # via flake8
pyflakes==1.2.3 # via flake8
Pygments==2.1.3
pytest-django==3.0.0
pytest==3.0.3
six==1.10.0 # via mock
18 changes: 18 additions & 0 deletions runtests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function

import os
import sys

import pytest


def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings')
sys.path.insert(0, 'tests')
return pytest.main()


if __name__ == '__main__':
sys.exit(main())
2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,4 @@
'Topic :: Software Development :: Libraries :: Python Modules',
],
install_requires=[],
tests_require=['mock >= 1.0'],
test_suite='tests.main',
)
File renamed without changes.
26 changes: 26 additions & 0 deletions tests/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import django
from django.conf import global_settings

SECRET_KEY = 'NOTASECRET'

INSTALLED_APPS = [
'corsheaders',
]

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'TEST_NAME': ':memory:',
},
}

ROOT_URLCONF = 'urls'


middlewares = list(global_settings.MIDDLEWARE_CLASSES)
middlewares.append('corsheaders.middleware.CorsMiddleware')

if django.VERSION >= (1, 10):
MIDDLEWARE = middlewares
else:
MIDDLEWARE_CLASSES = middlewares
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ deps =
django18: Django>=1.8,<1.9
django19: Django>=1.9,<1.10
django110: Django>=1.10,<1.11
commands = python setup.py test
commands = ./runtests.py {posargs}

[testenv:py27-codestyle]
commands = multilint
Expand Down

0 comments on commit e8ef113

Please sign in to comment.