-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fleshed out testing section a bit, cleaned up a few things
- Loading branch information
Scott Torborg
committed
Nov 18, 2012
1 parent
1302d47
commit e1be75a
Showing
4 changed files
with
45 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,42 @@ | ||
Let There Be Tests | ||
------------------ | ||
|
||
.. todo:: | ||
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.:: | ||
|
||
Explain basics of configuring nose, requiring it, and using the setup.py integration. | ||
funniest/ | ||
funniest/ | ||
__init__.py | ||
tests/ | ||
__init__.py | ||
test_joke.py | ||
setup.py | ||
... | ||
|
||
The ``test_joke.py`` 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 <https://nose.readthedocs.org/en/latest/>`_. With those files added, it's just a matter of running this from the root of the repository:: | ||
|
||
$ nosetests | ||
|
||
To integrate this with our ``setup.py``, and ensure that Nose is installed when we run the tests, we'll add a few lines to ``setup()``:: | ||
|
||
setup( | ||
... | ||
test_suite='nose.collector', | ||
tests_require=['nose'], | ||
) | ||
|
||
Then, to run tests, we can simply do:: | ||
|
||
$ python setup.py test | ||
|
||
Setuptools will take care of installing nose and running the test suite. |