1. Tarek Ziadé
  2. hitchhiker-guide-packaging
Issue #11 new

How does one run tests?

Anonymous created an issue

How does one go about running the tests (if any) in the 'test' directory? I thought that it would be something like:

$ python setup.py test

I've been experimenting on a nicely put together package that includes tests (http://hg.python.org/unittest2), and I can't figure out how to run them at all...

Surely tests are a vital part of the distribution story?

PS. Otherwise a great guide, thank you! :-D

Comments (3)

  1. Anonymous

    What I ended up doing was putting a 'test' sub-folder/package in the folder with my source (ie. the one under the root where my setup.py is), then writing a manual test runner script:

    setup.py
    test_runner.py
    myproject/foo.py
    myproject/bar.py
    myproject/test/foo_test.py
    myproject/test/bar_test.py
    

    It works well, but being able to run tests using the syntax you gave would be great!

    (remembering to set an error code...)

    $ python3 setup.py test
    .......................
    ----------------------------------------------------------------------
    Ran 23 tests in 0.453s 
    OK
    
    $ echo $?
    0
    
  2. Log in to comment