Abstract
Many programmers manually test the code they are writing by calling the piece of code they are developing, printing the result to the console, and visually scanning the output for correctness. This works for simple tasks but suffers from some problems:
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
It actually raises an IndexError, from trying to access the last element of the sorted list, which is empty.
- 2.
Wikipedia, “Dependency injection,” https://en.wikipedia.org/wiki/Dependency_injection , 2018.
- 3.
Python Software Foundation, “unittest.mock—mock object library,” https://docs.python.org/3/library/unittest.mock.html , 2018.
- 4.
- 5.
- 6.
Pytest, “pytest: helps you write better programs,” https://docs.pytest.org/en/latest/ , 2018.
- 7.
tox, “Welcome to the tox Automation Project,” https://tox.readthedocs.io/en/latest/ , 2018.
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2019 Moritz Lenz
About this chapter
Cite this chapter
Lenz, M. (2019). Unit Testing in Python. In: Python Continuous Integration and Delivery. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-4281-0_2
Download citation
DOI: https://doi.org/10.1007/978-1-4842-4281-0_2
Published:
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4842-4280-3
Online ISBN: 978-1-4842-4281-0
eBook Packages: Professional and Applied ComputingApress Access BooksProfessional and Applied Computing (R0)