NPRG065: Programming in Python - D3S
NPRG065: Programming
in Python
Lecture 13
Tomas Bures
Petr Hnetynka
{bures,hnetynka}@d3s.mff.cuni.cz
CHARLES UNIVERSITY IN PRAGUE
faculty of mathematics and physics
Unit testing
2
Unit testing
unit testing
testing small units of functionality
a unit C independent on other ones
tests are separated
creating helper objects for tests
context
typically in OO languages
unit ~ method
ideally C unit tests for all units in a program
typically in OO languages
for all public methods
3
Unit testing in Python
Modules in std. library
doctest
unittest
4
doctest
Placing testing code in pydoc comments
def echo(value):
"""
Documentation here
>>> echo(0)
0
"""
return value
Code to be executed as a test
Expected value of the test
Executing tests
python -m doctest -v example.py
Or
placing doctest.testmod() to main and executing the
module with the argument -v
See
doctesting.py
5
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- macro programming in excel
- programming in excel
- programming in java pdf
- sort dictionary in python by values
- programming in matlab
- object oriented programming in matlab
- programming in basic
- database programming in java
- database programming in python
- run python script in python shell
- object oriented programming in python
- python programming in visual studio