Skip to content

Commit

Permalink
tests: fix py.test integration with setuptools
Browse files Browse the repository at this point in the history
* Addresses issue when to tests where executed using
  `python setup.py test`.  (closes #17)

Signed-off-by: Jiri Kuncar <jiri.kuncar@cern.ch>
  • Loading branch information
jirikuncar committed Aug 27, 2014
1 parent 55a10de commit 9a03dcf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ python:

install:
- pip install --upgrade pip --use-mirrors
- pip install coverage --use-mirrors
- pip install pytest pytest-cache pytest-pep8 pytest-cov --use-mirrors
- pip install coveralls --use-mirrors
- pip install .

script:
- python -m pytest
- python setup.py test

after_success:
- coveralls
Expand Down
23 changes: 11 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@
# under the terms of the Revised BSD License; see COPYING.txt file for
# more details.

try:
from setuptools import setup
except:
from distutils.core import setup
"""Setup script for workflow package."""

import os
import re
import sys

from setuptools import setup
from setuptools.command.test import test as TestCommand


Expand All @@ -32,9 +30,8 @@ def finalize_options(self):

def run_tests(self):
# import here, cause outside the eggs aren't loaded
import pytest
errno = pytest.main()
sys.exit(errno)
import subprocess
raise SystemExit(subprocess.call([sys.executable, '-m', 'pytest']))


# Get the version string. Cannot be done with import!
Expand All @@ -44,6 +41,11 @@ def run_tests(self):
f.read()
).group('version')

tests_require = [
'pytest', 'pytest-cache', 'pytest-cov', 'pytest-pep8',
'coverage'
]

setup(
name='workflow',
packages=['workflow', 'workflow.patterns'],
Expand Down Expand Up @@ -71,12 +73,9 @@ def run_tests(self):
'Topic :: Software Development :: Libraries :: Application Frameworks',
'Topic :: Utilities',
],
tests_require=[
'pytest', 'pytest-cache', 'pytest-cov', 'pytest-pep8',
'coverage'
],
tests_require=tests_require,
cmdclass={'test': PyTest},
install_requires=['configobj>4.7.0', 'six'],
install_requires=['configobj>4.7.0', 'six'] + tests_require,
long_description="""\
Simple workflows for Python
-------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ envlist = py26, py27, py33, py34
deps = pytest
pytest-cov
pytest-pep8
commands = {envpython} -m pytest
commands = {envpython} setup.py test

0 comments on commit 9a03dcf

Please sign in to comment.