From fc9c721d96b1981f0f1661c8618851a36985c061 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Nut=CC=A6iu?= Date: Fri, 21 Apr 2017 01:41:24 +0300 Subject: [PATCH] Adding docttest to to_zero_count() --- src/resources/utilities.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/resources/utilities.py b/src/resources/utilities.py index a0b9026..52a3eef 100644 --- a/src/resources/utilities.py +++ b/src/resources/utilities.py @@ -21,6 +21,11 @@ def to_zero_count(page_no): """ Will subtract 1 from the argument it gets, converting it to an int. If the conversion fails or the argument it's negatives it returns zero instead. + + >>> to_zero_count(3) + 2 + >>> to_zero_count('a') + 0 Args: page_no: An integer @@ -28,6 +33,7 @@ def to_zero_count(page_no): Returns: It returns page_no - 1 if page_no can be safely converted to an integer else it returns zero. If page_no is negative, it returns zero. + """ try: page_no = int(page_no) - 1