Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run test suite in python setup.py

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?

like image 990
rlandster Avatar asked Jan 06 '14 02:01

rlandster


People also ask

How do I run a test in setup py?

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.

How do I run a setup py file?

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.

How do you use assertRaises in Python?

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.


1 Answers

Pretty simple, add the following to your setup() call:

test_suite="tests",   
like image 193
saschpe Avatar answered Oct 06 '22 02:10

saschpe