This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
python_cookbook [2019/01/29 13:59] mantis [Spline Polynoms] |
python_cookbook [2019/03/05 09:50] mantis |
||
---|---|---|---|
Line 1854: | Line 1854: | ||
(found in comments [[http://programmingpraxis.com/2012/05/29/streaming-median/|here]] - damn I hate paywalls. I'd love to read the piglet tracking paper!) | (found in comments [[http://programmingpraxis.com/2012/05/29/streaming-median/|here]] - damn I hate paywalls. I'd love to read the piglet tracking paper!) | ||
- | ====== Unit Tests ====== | + | ====== Testing ====== |
+ | |||
+ | ===== unittest ===== | ||
* Python 2 https://docs.python.org/2.7/library/unittest.html | * Python 2 https://docs.python.org/2.7/library/unittest.html | ||
* python 3 https://docs.python.org/3.4/library/unittest.html | * python 3 https://docs.python.org/3.4/library/unittest.html | ||
* http://agiletesting.blogspot.com/2005/01/python-unit-testing-part-1-unittest.html the nutshell | * http://agiletesting.blogspot.com/2005/01/python-unit-testing-part-1-unittest.html the nutshell | ||
- | ===== Basics ===== | + | ==== Basics ==== |
<code python> | <code python> | ||
import unittest | import unittest | ||
Line 1876: | Line 1879: | ||
</code> | </code> | ||
- | ===== classwide Setup and teardown ===== | + | ==== classwide Setup and teardown ==== |
There are two class methods that are called before/after tests in an individual class run. | There are two class methods that are called before/after tests in an individual class run. | ||
Line 1904: | Line 1907: | ||
</code> | </code> | ||
- | ===== Test for exceptions ===== | + | ==== Test for exceptions ==== |
Since [[http://docs.python.org/2/library/unittest.html#unittest.TestCase.assertRaises|python 2.7]] this is best done by using the context manager returned by unittest.assertRaises() | Since [[http://docs.python.org/2/library/unittest.html#unittest.TestCase.assertRaises|python 2.7]] this is best done by using the context manager returned by unittest.assertRaises() |