Skip to content

Commit

Permalink
Merge pull request #148 from boxine/fixes
Browse files Browse the repository at this point in the history
Fix ZeroDivisionError and doctests
  • Loading branch information
phihag authored Feb 27, 2024
2 parents 2d37f25 + 8f3f6bc commit 1886fa9
Show file tree
Hide file tree
Showing 7 changed files with 1,850 additions and 2,829 deletions.
8 changes: 6 additions & 2 deletions huey_monitor/humanize.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def percentage(num, total) -> str | None:
'25%'
>>> percentage(33.333, 100)
'33%'
>>> percentage(123, 0)
None
>>> percentage(123, 0) is None
True
"""
if not total:
return None
Expand All @@ -70,11 +70,15 @@ def throughput(num, elapsed_sec, suffix='', divisor=1000) -> str:
'2.00kBytes/s'
>>> throughput(4, 250, suffix='subtask')
'1.0\xa0minutes/subtask'
>>> throughput(123, 0)
'∞'
"""
if num == 0:
if suffix:
return f'0/{suffix}'
return '0'
if elapsed_sec == 0:
return '∞'
rate = num / elapsed_sec

if rate > 1:
Expand Down
17 changes: 17 additions & 0 deletions huey_monitor_project/tests/test_doctest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from bx_py_utils.test_utils.unittest_utils import BaseDocTests, DocTestResults

import huey_monitor
import huey_monitor_project


class DocTests(BaseDocTests):
def test_doctests(self):
results: DocTestResults = self.run_doctests(
modules=(
huey_monitor,
huey_monitor_project,
)
)
self.assertGreaterEqual(results.passed, 25)
self.assertEqual(results.skipped, 0)
self.assertLessEqual(results.failed, 0)
1,156 changes: 453 additions & 703 deletions requirements.dev.txt

Large diffs are not rendered by default.

1,162 changes: 456 additions & 706 deletions requirements.django32.txt

Large diffs are not rendered by default.

1,156 changes: 453 additions & 703 deletions requirements.django42.txt

Large diffs are not rendered by default.

1,156 changes: 453 additions & 703 deletions requirements.django50.txt

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ asgiref==3.7.2 \
--hash=sha256:89b2ef2247e3b562a16eef663bc0e2e703ec6468e2fa8a5cd61cd449786d4f6e \
--hash=sha256:9e0ce3aa93a819ba5b45120216b23878cf6e8525eb3848653452b4192b92afed
# via django
bx-django-utils==70 \
--hash=sha256:41c8bd54c0eab07ce914ec7bf3eca115324fba577b158a89d827b4312a4e6a98 \
--hash=sha256:dfc2db1ef019c51ea446687dff1602f75984f3bc410426d3c3ff34d2fab58f1a
bx-django-utils==71 \
--hash=sha256:5bbd281d43267a0922d5a8827ac70b5884bffe74e037663e17ad6d3f8264428c \
--hash=sha256:8ace0ef3dbf3a7f3630d8b6d49852371512fdbd168636b96874ba6a09aaa89f5
# via django-huey-monitor (pyproject.toml)
bx-py-utils==90 \
--hash=sha256:2c15b3b7d8a8e4f0bc6815517fb732fb303ce6878c3e45bbd60633b2811bf0ea \
--hash=sha256:bb8aa9bd59b6c733cc8fe65340a98bbff026bbc5aa3c3c01324f27d84b8c9302
bx-py-utils==91 \
--hash=sha256:d7b595ccafd1b06165d76086760864353b8f561db23398a383e0a49bbd0bcb7d \
--hash=sha256:feb75b3b2cdadac5ca034a6b874490f7516d9bcf4980854a0d48703289c387c9
# via
# bx-django-utils
# django-huey-monitor (pyproject.toml)
django==5.0 \
--hash=sha256:3a9fd52b8dbeae335ddf4a9dfa6c6a0853a1122f1fb071a8d5eca979f73a05c8 \
--hash=sha256:7d29e14dfbc19cb6a95a4bd669edbde11f5d4c6a71fdaa42c2d40b6846e807f7
django==5.0.2 \
--hash=sha256:56ab63a105e8bb06ee67381d7b65fe6774f057e41a8bab06c8020c8882d8ecd4 \
--hash=sha256:b5bb1d11b2518a5f91372a282f24662f58f66749666b0a286ab057029f728080
# via
# bx-django-utils
# django-huey-monitor (pyproject.toml)
Expand All @@ -35,7 +35,7 @@ sqlparse==0.4.4 \
--hash=sha256:5430a4fe2ac7d0f93e66f1efc6e1338a41884b7ddf2a350cedd20ccc4d9d28f3 \
--hash=sha256:d446183e84b8349fa3061f0fe7f06ca94ba65b426946ffebe6e3e8295332420c
# via django
typing-extensions==4.9.0 \
--hash=sha256:23478f88c37f27d76ac8aee6c905017a143b0b1b886c3c9f66bc2fd94f9f5783 \
--hash=sha256:af72aea155e91adfc61c3ae9e0e342dbc0cba726d6cba4b6c72c1f34e47291cd
typing-extensions==4.10.0 \
--hash=sha256:69b1a937c3a517342112fb4c6df7e72fc39a38e7891a5730ed4985b5214b5475 \
--hash=sha256:b0abd7c89e8fb96f98db18d86106ff1d90ab692004eb746cf6eda2682f91b3cb
# via asgiref

0 comments on commit 1886fa9

Please sign in to comment.