From 3a9a7d9317a3f253d56278ca24354e4adf2a4d01 Mon Sep 17 00:00:00 2001 From: Piotr Gredowski Date: Fri, 28 Jul 2023 09:41:52 +0200 Subject: [PATCH] Add more doctests --- src/_pieces/calculator.py | 13 ++++++++++--- src/_pieces/numbers.txt | 1 - 2 files changed, 10 insertions(+), 4 deletions(-) delete mode 100644 src/_pieces/numbers.txt diff --git a/src/_pieces/calculator.py b/src/_pieces/calculator.py index e110a0d..3ea60bc 100644 --- a/src/_pieces/calculator.py +++ b/src/_pieces/calculator.py @@ -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 @@ -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 """ diff --git a/src/_pieces/numbers.txt b/src/_pieces/numbers.txt deleted file mode 100644 index b8a7923..0000000 --- a/src/_pieces/numbers.txt +++ /dev/null @@ -1 +0,0 @@ -45, 67