Skip to content

Commit

Permalink
Started migrating to pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
silvanocerza committed Feb 12, 2017
1 parent 966d116 commit 4a73df2
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 48 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ lib64
pip-log.txt

# Unit test / coverage reports
.cache
.coverage
.tox
nosetests.xml
Expand Down
6 changes: 4 additions & 2 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
py-moneyed==0.6.0
mock>=1.0.1
nose>=1.3.0
django-nose>=1.2
pytest-mock==1.2
pytest==2.9.2
pytest-django==3.1.2


# Additional test requirements go here
47 changes: 2 additions & 45 deletions runtests.py
Original file line number Diff line number Diff line change
@@ -1,47 +1,4 @@
import sys
from optparse import OptionParser
import pytest

try:
from django.conf import settings

settings.configure(
DEBUG=True,
USE_TZ=True,
DATABASES={
"default": {
"ENGINE": "django.db.backends.sqlite3",
}
},
ROOT_URLCONF="djmoney_rates.urls",
INSTALLED_APPS=[
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sites",
"djmoney_rates",
],
SITE_ID=1,
NOSE_ARGS=['-s'],
)

from django_nose import NoseTestSuiteRunner
except ImportError:
raise ImportError("To fix this error, run: pip install -r requirements-test.txt")


def run_tests(*test_args):
if not test_args:
test_args = ['tests']

# Run tests
test_runner = NoseTestSuiteRunner(verbosity=1)

failures = test_runner.run_tests(test_args)

if failures:
sys.exit(failures)


if __name__ == '__main__':
parser = OptionParser()
(options, args) = parser.parse_args()
run_tests(*args)
sys.exit(pytest.main())
29 changes: 29 additions & 0 deletions tests/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
USE_TZ = True

DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": "example.sqlite",
}
}

ROOT_URLCONF = "djmoney_rates.urls"

INSTALLED_APPS = [
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sites",
"djmoney_rates",
]

SECRET_KEY = "1234567890evonove"

TEMPLATES = [
{
'OPTIONS': {
'debug': True,
}
}
]

SITE_ID = 1
6 changes: 5 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[pytest]
DJANGO_SETTINGS_MODULE=tests.settings
testpaths=tests

[tox]
envlist =
py27-django{18,19,110,master},
Expand All @@ -19,7 +23,7 @@ deps =
setenv =
PYTHONPATH = {toxinidir}:{toxinidir}/djmoney_rates
commands =
coverage run -a runtests.py
python runtests.py

[testenv:flake8]
deps =
Expand Down

0 comments on commit 4a73df2

Please sign in to comment.