Skip to content

Commit

Permalink
Maybe a test? [for review by DRMaccIver]
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed May 22, 2017
1 parent 876cf9d commit 251dcd4
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions tests/cover/test_datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@

from flaky import flaky

from hypothesis import given, settings
from hypothesis import find, given, settings
from tests.common.debug import minimal
from hypothesis.strategies import dates, times, datetimes, timedeltas
from hypothesis.strategies import none, dates, times, binary, datetimes, \
timedeltas
from hypothesis.strategytests import strategy_test_suite
from hypothesis.internal.compat import hrange
from hypothesis.searchstrategy.datetime import DatetimeStrategy
from hypothesis.internal.conjecture.data import ConjectureData

TestStandardDescriptorFeatures_timedeltas1 = strategy_test_suite(timedeltas())

Expand Down Expand Up @@ -89,6 +92,19 @@ def test_bordering_on_a_leap_year():
assert x.year == 2004


def test_DatetimeStrategy_draw_may_fail():
strat = DatetimeStrategy(dt.datetime.min, dt.datetime.max, none())
failure_inducing = find(
binary(min_size=30),
lambda b: strat._attempt_one_draw(
ConjectureData.for_buffer(b)) is None
)
data = ConjectureData.for_buffer(failure_inducing)
data.draw(strat) # Should raise some kind of error?
assert data.buffer
assert data.buffer == failure_inducing[:len(data.buffer)]


TestStandardDescriptorFeatures_dates1 = strategy_test_suite(dates())


Expand Down

0 comments on commit 251dcd4

Please sign in to comment.