Skip to content

Instantly share code, notes, and snippets.

@AndyLPK247
Created March 11, 2017 05:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndyLPK247/6c691c8dd1c9cf44ec986ba45d8ceb9f to your computer and use it in GitHub Desktop.
Save AndyLPK247/6c691c8dd1c9cf44ec986ba45d8ceb9f to your computer and use it in GitHub Desktop.
Python Testing 101 doctest Example: Calculator Doctests
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