Skip to content

Commit

Permalink
[tests] Use PyTest instead of Nose (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishek776 committed Sep 13, 2016
1 parent 7f62d96 commit 72dc2c6
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 47 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -6,7 +6,9 @@
dist/
*.egg-info
*.egg
*.eggs/
*.egg/
*.cache/
build/
.build/
_build/
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion requirements/test.txt
@@ -1,3 +1,4 @@
django-nose==1.4.4
mock==2.0.0
coverage>=3.0
pytest-django>=3.0.0,<4.0.0
pytest-runner>=2.9,<3.0
8 changes: 6 additions & 2 deletions setup.cfg
@@ -1,5 +1,9 @@
[nosetests]
where = deux/tests
[aliases]
test=pytest

[tool:pytest]
DJANGO_SETTINGS_MODULE = test_proj.settings
testpaths = deux

[wheel]
universal = 1
Expand Down
35 changes: 0 additions & 35 deletions setup.py
Expand Up @@ -121,39 +121,6 @@ def reqs(*f):
else:
long_description = 'See http://pypi.python.org/pypi/%s' % (NAME,)

# -*- %%% -*-

class RunTests(Command):
description = 'Run the test suite.'
user_options = []
extra_env = {}
extra_args = []

def run(self):
for env_name, env_value in self.extra_env.items():
os.environ[env_name] = str(env_value)

this_dir = os.getcwd()
testproj_dir = os.path.join(this_dir, 'test_proj')
os.chdir(testproj_dir)
sys.path.append(testproj_dir)
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'test_proj.settings')
import django
django.setup()
from django.core.management import execute_from_command_line
prev_argv = list(sys.argv)
try:
sys.argv = [__file__, 'test'] + self.extra_args
execute_from_command_line(argv=sys.argv)
finally:
sys.argv = prev_argv

def initialize_options(self):
pass

def finalize_options(self):
pass


setup(
name=NAME,
Expand All @@ -169,8 +136,6 @@ def finalize_options(self):
zip_safe=False,
install_requires=reqs('default.txt'),
tests_require=reqs('test.txt'),
test_suite='nose.collector',
classifiers=classifiers,
long_description=long_description,
cmdclass={'test': RunTests},
)
8 changes: 0 additions & 8 deletions test_proj/settings.py
Expand Up @@ -15,14 +15,6 @@
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
NOSE_ARGS = [
'deux.authtoken.tests',
'deux.oauth2.tests',
'deux.tests',
]


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/

Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Expand Up @@ -27,7 +27,7 @@ deps=
flake8,flakeplus: -r{toxinidir}/requirements/pkgutils.txt
sitepackages = False
recreate = False
commands = coverage run ./test_proj/manage.py test -x
commands = coverage run setup.py test

basepython =
2.7,flake8,flakeplus,apicheck,linkcheck,configcheck: python2.7
Expand Down

0 comments on commit 72dc2c6

Please sign in to comment.