diff --git a/maya.py b/maya.py index 4415f84..37f4557 100644 --- a/maya.py +++ b/maya.py @@ -62,7 +62,7 @@ class MayaDT(object): @validate_class_type_arguments('==') def __eq__(self, maya_dt): - return self._epoch == maya_dt._epoch + return int(self._epoch) == int(maya_dt._epoch) @validate_class_type_arguments('!=') def __ne__(self, maya_dt): @@ -85,7 +85,7 @@ class MayaDT(object): return self._epoch >= maya_dt._epoch def __hash__(self): - return hash(self.epoch) + return hash(int(self.epoch)) def __add__(self, item): return self.add(seconds=seconds_or_timedelta(item).total_seconds()) diff --git a/test_maya_interval.py b/test_maya_interval.py index 03b5e5c..2e7c0dd 100755 --- a/test_maya_interval.py +++ b/test_maya_interval.py @@ -34,9 +34,9 @@ def test_interval_requires_2_of_start_end_duration(): def test_interval_requires_end_time_after_or_on_start_time(): - maya.MayaInterval(start=maya.now(), duration=0) with pytest.raises(ValueError): + maya.MayaInterval(start=maya.now(), duration=0) maya.MayaInterval(start=maya.now(), duration=-1) @@ -464,11 +464,14 @@ def test_interval_flatten_non_overlapping(): def test_interval_flatten_adjacent(): step = 2 max_hour = 20 - base = maya.now() - intervals = [maya.MayaInterval( - start=base.add(hours=hour), - duration=timedelta(hours=step), - ) for hour in range(0, max_hour, step)] + base = maya.when('jan/1/2011') + + intervals = [ + maya.MayaInterval( + start=base.add(hours=hour), + duration=timedelta(hours=step), + ) for hour in range(0, max_hour, step) + ] random.shuffle(intervals) assert maya.MayaInterval.flatten(intervals) == [maya.MayaInterval(