Commits

Anonymous committed fc3dc42

Added test and implementation to disallow negative hours.

  • Participants
  • Parent commits 1ca7976

Comments (0)

Files changed (1)

File hours2days.py

     Traceback (most recent call last):
     ...
     ValueError: base must be between 1 and 24 got 120.00
+    >>> hours2days(-5)
+    Traceback (most recent call last):
+    ...
+    ValueError: hours must be positive number got -5.00
     """
     if not 1 <= base <= 24:
         msg = 'base must be between 1 and 24 got {0:5.2f}'.format(base)
         raise ValueError(msg)
+    if hours < 0:
+        msg = 'hours must be positive number got {0:5.2f}'.format(hours)
+        raise ValueError(msg)
     base = float(base)
     days = (hours + minutes / 60.) / base
     if precision: