Skip to content

Commit da04e6d

Browse files
committed
add setup.py test command
1 parent e882000 commit da04e6d

File tree

1 file changed

+34
-13
lines changed

1 file changed

+34
-13
lines changed

setup.py

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from setuptools import setup, find_packages
2+
from setuptools.command.test import test as TestCommand
23
import sys
34

45
if sys.version_info[0] < 3:
@@ -12,10 +13,39 @@
1213
# the numpy distutils extensions that are used by scikit-learn to recursively
1314
# build the compiled extensions in sub-packages is based on the Python import
1415
# machinery.
15-
builtins.__GRAPHQL_SETUP__ = True
16+
if 'test' not in sys.argv:
17+
builtins.__GRAPHQL_SETUP__ = True
1618

1719
version = __import__('graphql').get_version()
1820

21+
install_requires = [
22+
'six>=1.10.0',
23+
'promise>=0.4.2'
24+
]
25+
26+
tests_requires = [
27+
'pytest==3.0.2',
28+
'pytest-django==2.9.1',
29+
'pytest-cov==2.3.1',
30+
'gevent==1.1rc1',
31+
'six>=1.10.0',
32+
'pytest-benchmark==3.0.0',
33+
'pytest-mock==1.2',
34+
]
35+
36+
class PyTest(TestCommand):
37+
def finalize_options(self):
38+
TestCommand.finalize_options(self)
39+
self.test_args = ['graphql', '-vrsx']
40+
self.test_suite = True
41+
42+
def run_tests(self):
43+
#import here, cause outside the eggs aren't loaded
44+
import pytest
45+
errno = pytest.main(self.test_args)
46+
sys.exit(errno)
47+
48+
1949
setup(
2050
name='graphql-core',
2151
version=version,
@@ -43,18 +73,9 @@
4373

4474
keywords='api graphql protocol rest',
4575
packages=find_packages(exclude=['tests', 'tests_py35']),
46-
install_requires=[
47-
'six>=1.10.0',
48-
'promise>=0.4.2'
49-
],
50-
tests_require=[
51-
'pytest==2.9.2',
52-
'pytest-benchmark',
53-
'pytest-cov',
54-
'gevent==1.1rc1',
55-
'six>=1.10.0',
56-
'pytest-mock'
57-
],
76+
install_requires=install_requires,
77+
tests_require=tests_requires,
78+
cmdclass = {'test': PyTest},
5879
extras_require={
5980
'gevent': [
6081
'gevent==1.1rc1'

0 commit comments

Comments
 (0)