Skip to content

Commit 6ed13df

Browse files
committed
Include pytest and mock as test requirements, together with a test
command to run the tests using "python setup.py test".
1 parent 742244d commit 6ed13df

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

setup.py

+23-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python
22

33
from setuptools import setup
4+
from setuptools.command.test import test as TestCommand
45
import re
56

67
for line in open('sklearn_pandas/__init__.py'):
@@ -9,6 +10,24 @@
910
__version__, = match.groups()
1011

1112

13+
class PyTest(TestCommand):
14+
user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")]
15+
16+
def initialize_options(self):
17+
TestCommand.initialize_options(self)
18+
self.pytest_args = []
19+
20+
def finalize_options(self):
21+
TestCommand.finalize_options(self)
22+
self.test_args = []
23+
self.test_suite = True
24+
25+
def run(self):
26+
import pytest
27+
errno = pytest.main(self.pytest_args)
28+
raise SystemExit(errno)
29+
30+
1231
setup(name='sklearn-pandas',
1332
version=__version__,
1433
description='Pandas integration with sklearn',
@@ -21,5 +40,7 @@
2140
'scikit-learn>=0.13',
2241
'scipy>=0.14',
2342
'pandas>=0.11.0',
24-
'numpy>=1.6.1']
25-
)
43+
'numpy>=1.6.1'],
44+
tests_require=['pytest', 'mock'],
45+
cmdclass={'test': PyTest},
46+
)

tests/test_dataframe_mapper.py

+4
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ def test_cols_list_column_vector():
9797

9898

9999
def test_list_transformers():
100+
"""
101+
Specifying a list of transformers applies them sequentially to the
102+
selected column.
103+
"""
100104
dataframe = pd.DataFrame({"a": [1, np.nan, 3], "b": [1, 5, 7]})
101105

102106
mapper = DataFrameMapper([

0 commit comments

Comments
 (0)