Skip to content

Commit

Permalink
Add more doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrgredowski authored and pgred-orsted committed Sep 9, 2024
1 parent 4afbeb9 commit 3a9a7d9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
13 changes: 10 additions & 3 deletions src/_pieces/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ class Calculator:
>>> calc.divide(10, 2)
5.0
# Storytelling:
### Testing parts we can't predict
>>> import random
>>> a, b = 1 + random.random(), 2
>>> calc.add(a, b)
3...
### Storytelling:
1. Let's prepare some data to use with the calculator. Use for that decimals
Expand All @@ -41,8 +48,8 @@ class Calculator:
>>> numbers = [1, 2, 3]
>>> calc.add(*numbers)
Traceback (most recent call last):
...
TypeError: Calculator.add() takes 3 positional arguments but 4 were given
...
TypeError: ...add() takes 3 positional arguments but 4 were given
And that's how we can use `Calculator` and write some story with doctest at the same time
"""
Expand Down
1 change: 0 additions & 1 deletion src/_pieces/numbers.txt

This file was deleted.

0 comments on commit 3a9a7d9

Please sign in to comment.