Created
March 11, 2017 05:08
-
-
Save AndyLPK247/6c691c8dd1c9cf44ec986ba45d8ceb9f to your computer and use it in GitHub Desktop.
Python Testing 101 doctest Example: Calculator Doctests
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
The ``com.automationpanda.example.calc_class`` module | |
===================================================== | |
>>> from com.automationpanda.example.calc_class import Calculator | |
>>> calc = Calculator() | |
>>> calc.add(3, 2) | |
5 | |
>>> calc.subtract(3, 2) | |
1 | |
>>> calc.subtract(2, 3) | |
-1 | |
>>> calc.multiply(3, 2) | |
6 | |
>>> calc.divide(3.0, 2.0) | |
1.5 | |
>>> calc.divide(1.0, 0) | |
Traceback (most recent call last): | |
... | |
ZeroDivisionError: float division by zero | |
>>> calc.maximum(3, 2) | |
3 | |
>>> calc.maximum(2, 3) | |
3 | |
>>> calc.maximum(3, 3) | |
3 | |
>>> calc.minimum(3, 2) | |
2 | |
>>> calc.minimum(2, 3) | |
2 | |
>>> calc.minimum(2, 2) | |
2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment