Skip to content

Commit

Permalink
Enable testing for datetime in invariance testing
Browse files Browse the repository at this point in the history
  • Loading branch information
rudigiesler authored and Sekenre committed Jun 2, 2023
1 parent 0639945 commit 760b820
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tests/hypothesis_strategies.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from collections import OrderedDict, defaultdict
from datetime import timedelta, timezone

from cbor2.types import FrozenDict
from hypothesis import strategies
Expand All @@ -7,6 +8,12 @@
MAX_SIZE = 5
MAX_LEAVES = 2

# Seconds in timezones get rounded when serialised, so we can only test whole minute
# timezones for invariance
timezones = strategies.integers(min_value=-(24 * 60 - 1), max_value=24 * 60 - 1).map(
lambda m: timezone(timedelta(minutes=m))
)

basic_immutable_strategy = strategies.one_of(
strategies.none(),
strategies.booleans(),
Expand All @@ -16,8 +23,7 @@
# nan != nan, so we can't test invariance with it
strategies.floats(allow_nan=False),
strategies.decimals(allow_nan=False),
# TODO: fix seconds in timezones
# strategies.datetimes(timezones=strategies.timezones()),
strategies.datetimes(timezones=timezones),
# TODO: this needs to be fetched from impl fixture instead of imported
# strategies.just(undefined),
strategies.fractions(),
Expand Down

0 comments on commit 760b820

Please sign in to comment.