Skip to content

Commit

Permalink
Merge pull request #113 from sprymix/microsecond-comparison-fix
Browse files Browse the repository at this point in the history
Add overlooked microsecond comparison in relativedelta.
  • Loading branch information
pganssle committed Aug 25, 2015
2 parents ca8e98b + 7cab191 commit 0935d20
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions dateutil/relativedelta.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ def __eq__(self, other):
self.hours == other.hours and
self.minutes == other.minutes and
self.seconds == other.seconds and
self.microseconds == other.microseconds and
self.leapdays == other.leapdays and
self.year == other.year and
self.month == other.month and
Expand Down
11 changes: 11 additions & 0 deletions dateutil/test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,17 @@ def testBoolean(self):
self.assertFalse(relativedelta(days=0))
self.assertTrue(relativedelta(days=1))

def testComparison(self):
d1 = relativedelta(years=1, months=1, days=1, leapdays=0, hours=1,
minutes=1, seconds=1, microseconds=1)
d2 = relativedelta(years=1, months=1, days=1, leapdays=0, hours=1,
minutes=1, seconds=1, microseconds=1)
d3 = relativedelta(years=1, months=1, days=1, leapdays=0, hours=1,
minutes=1, seconds=1, microseconds=2)

self.assertEqual(d1, d2)
self.assertNotEqual(d1, d3)

def testWeeks(self):
# Test that the weeks property is working properly.
rd = relativedelta(years=4, months=2, weeks=8, days=6)
Expand Down

0 comments on commit 0935d20

Please sign in to comment.