I am trying to setup a Python package using setup.py
. My directory structure looks like this:
setup.py
baxter/
__init__.py
baxter.py
tests/
test_baxter.py
Here is setup.py
:
from setuptools import setup, find_packages
setup(name='baxter',
version='1.0',
packages=find_packages()
)
I first do a python setup.py build
. When I then run python setup.py test
I immediately get this result:
running test
and nothing else. The unit tests have not run since the tests take at least 15 seconds to finish and the message running test
comes back right away.
So it appears that python setup.py test
is not finding the unit tests. What am I doing wrong?
You can just specify test_suite="tests", and it will pick up everything recursively. Note that each nested directory will need to have an __init__.py file in it. You need to do from setuptools import setup instead of from distutils. core import setup for this option to exist.
To install a package that includes a setup.py file, open a command or terminal window and: cd into the root directory where setup.py is located. Enter: python setup.py install.
There are two ways you can use assertRaises: using keyword arguments. Just pass the exception, the callable function and the parameters of the callable function as keyword arguments that will elicit the exception. Make a function call that should raise the exception with a context.
Pretty simple, add the following to your setup() call:
test_suite="tests",
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With