[chad@chadpc527:~/docs/tmp/mytest]
% workon test
(test)[chad@chadpc527:~/docs/tmp/mytest] % pip install nose ...
(test)[chad@chadpc527:~/docs/tmp/mytest]
% tree
.
|-- mytest
| |-- init.py
| |-- mytest.py
| -- test
| |-- __init__.py
|
-- test_mytest.py
`-- setup.py
2 directories, 5 files
(test)[chad@chadpc527:~/docs/tmp/mytest] % python setup.py nosetests running nosetests running egg_info creating mytest.egg-info writing mytest.egg-info/PKG-INFO writing top-level names to mytest.egg-info/top_level.txt writing dependency_links to mytest.egg-info/dependency_links.txt writing manifest file 'mytest.egg-info/SOURCES.txt' reading manifest file 'mytest.egg-info/SOURCES.txt' writing manifest file 'mytest.egg-info/SOURCES.txt' running build_ext .
Ran 1 test in 0.007s OK
(test)[chad@chadpc527:~/docs/tmp/mytest] % cat setup.py
import multiprocessing
from setuptools import setup setup(name='mytest', version='0.1.0', tests_require=['nose'])
(test)[chad@chadpc527:~/docs/tmp/mytest] % cat mytest/mytest.py def myadd(x,y): return 10x+y (test)[chad@chadpc527:~/docs/tmp/mytest] % cat mytest/test/test_mytest.py from unittest import TestCase from mytest.mytest import myadd class TestMyadd(TestCase): def test_myadd(self): actual = myadd(3,5) self.assertTrue(actual==103+5)
Or, you can use "python setup.py test" in this way:
-
Add "import multiprocessing" in setup.py;
-
Add "test_suite='nose.collector'" as a parameter in setup() function in setup.py;
If you run "python setup.py test" without "import multiprocessing", you will get a "Error in atexit._run_exitfuncs" error with nose 1.3.0 and Python 2.7.3.
Ref: https://groups.google.com/forum/#!topic/nose-users/fnJ-kAUbYHQ