Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
44 lines (30 sloc) 1.37 KB

Let There Be Tests

The funniest package needs some tests. These should be placed in a submodule of funniest. so that they can be imported, but won't pollute the global namespace.:


The file is our first test file. Although it's overkill for now, we'll use a unittest.TestCase subclass to provide infrastructure for later development.:

from unittest import TestCase

import funniest

class TestJoke(TestCase):
    def test_is_string(self):
        s = funniest.joke()
        self.assertTrue(isinstance(s, basestring))

The best way to get these tests going (particularly if you're not sure what to use) is Nose. With those files added, it's just a matter of running this from the root of the repository:

$ pip install nose
$ nosetests

To integrate this with our, and ensure that Nose is installed when we run the tests, we'll add a few lines to setup():


Then, to run tests, we can simply do:

$ python test

Setuptools will take care of installing nose and running the test suite.

You can’t perform that action at this time.