Skip to content

Commit

Permalink
Merge pull request #760 from lucaferocino/master
Browse files Browse the repository at this point in the history
Add tests to take relativedelta.py to 100% coverage
  • Loading branch information
pganssle committed Jun 9, 2018
2 parents 10e23cc + 08e2154 commit 737ed6b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ switch, and thus all their contributions are dual-licensed.
- Kubilay Kocak <koobs@MASKED>
- Laszlo Kiss Kollar <kiss.kollar.laszlo@MASKED> (gh: @lkollar) **D**
- Lauren Oldja <oldja@MASKED> (gh: @loldja)
- Luca Ferocino <luca.ferox@MASKED> (gh: @lucaferocino)
- Luca Ferocino <luca.ferox@MASKED> (gh: @lucaferocino) **D**
- Mario Corchero <mcorcherojim@MASKED> (gh: @mariocj89) **R**
- Mateusz Dziedzic (gh: @m-dz) **D**
- Matthew Schinckel <matt@MASKED>
Expand Down
1 change: 1 addition & 0 deletions changelog.d/760.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added tests to bring relativedelta.py to 100% test coverage. Contribution by @lucaferocino (gh issue #521, gh pr #760).
18 changes: 18 additions & 0 deletions dateutil/test/test_relativedelta.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ def testNextWenesdayNotToday(self):
self.assertEqual(self.today+relativedelta(days=+1, weekday=WE),
date(2003, 9, 24))

def testAddMoreThan12Months(self):
self.assertEqual(date(2003, 12, 1) + relativedelta(months=+13),
date(2005, 1, 1))

def testAddNegativeMonths(self):
self.assertEqual(date(2003, 1, 1) + relativedelta(months=-2),
date(2002, 11, 1))

def test15thISOYearWeek(self):
self.assertEqual(date(2003, 1, 1) +
relativedelta(day=4, weeks=+14, weekday=MO(-1)),
Expand Down Expand Up @@ -350,6 +358,16 @@ def testRelativeDeltaFractionalMonth(self):
with self.assertRaises(ValueError):
relativedelta(months=1.5)

def testRelativeDeltaInvalidDatetimeObject(self):
with self.assertRaises(TypeError):
relativedelta(dt1='2018-01-01', dt2='2018-01-02')

with self.assertRaises(TypeError):
relativedelta(dt1=datetime(2018, 1, 1), dt2='2018-01-02')

with self.assertRaises(TypeError):
relativedelta(dt1='2018-01-01', dt2=datetime(2018, 1, 2))

def testRelativeDeltaFractionalAbsolutes(self):
# Fractional absolute values will soon be unsupported,
# check for the deprecation warning.
Expand Down

0 comments on commit 737ed6b

Please sign in to comment.