Skip to content

Commit 94f0906

Browse files
committed
Remove pytest-runner dependency
To support "python setup.py test", add a setuptools command within setup.py to achieve this. the pytest-runner needlessly requires a global build requirement.
1 parent 29d4b1b commit 94f0906

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

setup.cfg

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,3 @@ addopts= --tb native -v -r fxX --ignore=sqlalchemy
55
python_files=sqlalchemy_collectd/*/test_*.py
66

77

8-
[aliases]
9-
test=pytest

setup.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
from setuptools import setup
22
from setuptools import find_packages
3+
from setuptools.command.test import test as TestCommand # noqa
34
import os
45
import re
6+
import sys
57

68

79
with open(
@@ -18,6 +20,26 @@
1820
'SQLAlchemy>=1.1',
1921
]
2022

23+
24+
class PyTest(TestCommand):
25+
user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")]
26+
27+
def initialize_options(self):
28+
TestCommand.initialize_options(self)
29+
self.pytest_args = []
30+
31+
def finalize_options(self):
32+
TestCommand.finalize_options(self)
33+
self.test_args = []
34+
self.test_suite = True
35+
36+
def run_tests(self):
37+
# import here, cause outside the eggs aren't loaded
38+
import pytest
39+
errno = pytest.main(self.pytest_args)
40+
sys.exit(errno)
41+
42+
2143
setup(
2244
name='sqlalchemy-collectd',
2345
version=VERSION,
@@ -38,7 +60,7 @@
3860
packages=find_packages(".", exclude=["*.tests"]),
3961
include_package_data=True,
4062
tests_require=['pytest', 'mock'],
41-
setup_requires=['pytest-runner'],
63+
cmdclass={'test': PyTest},
4264
zip_safe=False,
4365
install_requires=requires,
4466
entry_points={

0 commit comments

Comments
 (0)