You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The deadline setting is given as a number of milliseconds, but users could mistake this number for seconds or microseconds. Fortunately, Python has a timedelta type which can easily express durations - it would be good to accept timedeltas as values for the deadline setting, and convert numeric deadlines to timedeltas for unambiguous display.
That would mean:
Modifying the hypothesis._settings._validate_deadline function to accept timedeltas as well as numbers, and to return a timedelta
Make the default value for the deadline setting a timedelta
Calculate runtime in hypothesis/core.py as a timedelta, instead of a number of milliseconds, so that the comparison works (ctrl-f for deadline to find this)
Add a test in hypothesis-python/tests/cover/test_settings.py that passes a timedelta as a deadline, to check that it works and get full coverage
[optionally] create a subclass of datetime.timedelta that gives the __repr__ in terms of milliseconds, and use it in hypothesis._settings._validate_deadline (only). e.g.:
Go for it! Per our usual policy, we'll reserve this issue for you for the next week 😄
Make sure you check the contributing guide - you'll need to add your name to the list of authors, and add a RELEASE.rst file, then go through the points above. If in doubt, open a work-in-progress pull request and I'll be happy to review it and help out!
The
deadlinesetting is given as a number of milliseconds, but users could mistake this number for seconds or microseconds. Fortunately, Python has atimedeltatype which can easily express durations - it would be good to accept timedeltas as values for thedeadlinesetting, and convert numeric deadlines to timedeltas for unambiguous display.That would mean:
hypothesis._settings._validate_deadlinefunction to accept timedeltas as well as numbers, and to return a timedeltadeadlinesetting a timedeltaruntimeinhypothesis/core.pyas a timedelta, instead of a number of milliseconds, so that the comparison works (ctrl-f fordeadlineto find this)hypothesis-python/tests/cover/test_settings.pythat passes a timedelta as a deadline, to check that it works and get full coveragedatetime.timedeltathat gives the__repr__in terms of milliseconds, and use it inhypothesis._settings._validate_deadline(only). e.g.:The text was updated successfully, but these errors were encountered: