D: [iurt_root_command] chroot warning: extra tokens at the end of %endif directive in line 18: %endif # if with_python3 warning: extra tokens at the end of %endif directive in line 42: %endif # with_python3 warning: extra tokens at the end of %endif directive in line 52: %endif # with_python3 warning: extra tokens at the end of %endif directive in line 58: %endif # with_python3 warning: extra tokens at the end of %endif directive in line 64: %endif # with_python3 warning: extra tokens at the end of %endif directive in line 71: %endif # with_python3 Installing /home/iurt/rpmbuild/SRPMS/python-findates-0.2-10.mga8.src.rpm Building target platforms: x86_64 Building for target x86_64 Executing(%prep): /bin/sh -e /home/iurt/rpmbuild/tmp/rpm-tmp.7aiZIE + umask 022 + cd /home/iurt/rpmbuild/BUILD + '[' 1 -eq 1 ']' + '[' 1 -eq 1 ']' + '[' 1 -eq 1 ']' + cd /home/iurt/rpmbuild/BUILD + rm -rf FinDates-0.2 + /usr/bin/unzip -qq /home/iurt/rpmbuild/SOURCES/FinDates-0.2.zip + STATUS=0 + '[' 0 -ne 0 ']' + cd FinDates-0.2 + /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w . + find -name '*.py' + xargs sed -i '1s|^#!python|#!/usr/bin/python3|' + find -name '*.py' + xargs 2to3 -w RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored ./findates/busdayrule.py RefactoringTool: No changes to ./findates/dateutils.py RefactoringTool: Refactored ./findates/__init__.py RefactoringTool: Refactored ./findates/test/test_findates.py --- ./findates/busdayrule.py (original) +++ ./findates/busdayrule.py (refactored) @@ -5,7 +5,7 @@ import datetime -import dateutils +from . import dateutils def _roll_forward(dt, calendar): rolled = dt --- ./findates/__init__.py (original) +++ ./findates/__init__.py (refactored) @@ -11,7 +11,7 @@ """ -from dateutils import * -from busdayrule import * -from daycount import * -from holidays import * +from .dateutils import * +from .busdayrule import * +from .daycount import * +from .holidays import * --- ./findates/test/test_findates.py (original) +++ ./findates/test/test_findates.py (refactored) @@ -65,13 +65,13 @@ self.assertTrue(iseom('31 Dec 2000')) def test_nweekday(self): - self.assertEquals(lweekday(2011, 9, 6).day, 25) - self.assertEquals(lweekday(2012, 1, 1).day, 31) - self.assertEquals(nweekday(2011, 9, 1, 0).day, 5) - self.assertEquals(nweekday(2012, 1, 1, 6).day, 1) - self.assertEquals(nweekday(2012, 1, 1, 0).day, 2) - self.assertEquals(nweekday(2012, 1, 2, 6).day, 8) - self.assertEquals(nweekday(2012, 1, 2, 0).day, 9) + self.assertEqual(lweekday(2011, 9, 6).day, 25) + self.assertEqual(lweekday(2012, 1, 1).day, 31) + self.assertEqual(nweekday(2011, 9, 1, 0).day, 5) + self.assertEqual(nweekday(2012, 1, 1, 6).day, 1) + self.assertEqual(nweekday(2012, 1, 1, 0).day, 2) + self.assertEqual(nweekday(2012, 1, 2, 6).day, 8) + self.assertEqual(nweekday(2012, 1, 2, 0).day, 9) def assertEaster(self, y, m, d): self.assertEqual(holidays.easter(y), datetime.datetime(y, m, d)) @@ -113,150 +113,150 @@ def test_rolldate(self): cal = holidays.get_calendar('ca') # test conventions on non-EOM holiday (Sat and Sun) - self.assertEquals(busdayrule.rolldate('21 Jan 2012', cal, 'follow'), datetime.datetime(2012, 1, 23)) - self.assertEquals(busdayrule.rolldate('22 Jan 2012', cal, 'follow'), datetime.datetime(2012, 1, 23)) - self.assertEquals(busdayrule.rolldate('21 Jan 2012', cal, 'modfollow'), datetime.datetime(2012, 1, 23)) - self.assertEquals(busdayrule.rolldate('22 Jan 2012', cal, 'modfollow'), datetime.datetime(2012, 1, 23)) - - self.assertEquals(busdayrule.rolldate('21 Jan 2012', cal, 'previous'), datetime.datetime(2012, 1, 20)) - self.assertEquals(busdayrule.rolldate('22 Jan 2012', cal, 'previous'), datetime.datetime(2012, 1, 20)) - self.assertEquals(busdayrule.rolldate('21 Jan 2012', cal, 'modprevious'), datetime.datetime(2012, 1, 20)) - self.assertEquals(busdayrule.rolldate('22 Jan 2012', cal, 'modprevious'), datetime.datetime(2012, 1, 20)) + self.assertEqual(busdayrule.rolldate('21 Jan 2012', cal, 'follow'), datetime.datetime(2012, 1, 23)) + self.assertEqual(busdayrule.rolldate('22 Jan 2012', cal, 'follow'), datetime.datetime(2012, 1, 23)) + self.assertEqual(busdayrule.rolldate('21 Jan 2012', cal, 'modfollow'), datetime.datetime(2012, 1, 23)) + self.assertEqual(busdayrule.rolldate('22 Jan 2012', cal, 'modfollow'), datetime.datetime(2012, 1, 23)) + + self.assertEqual(busdayrule.rolldate('21 Jan 2012', cal, 'previous'), datetime.datetime(2012, 1, 20)) + self.assertEqual(busdayrule.rolldate('22 Jan 2012', cal, 'previous'), datetime.datetime(2012, 1, 20)) + self.assertEqual(busdayrule.rolldate('21 Jan 2012', cal, 'modprevious'), datetime.datetime(2012, 1, 20)) + self.assertEqual(busdayrule.rolldate('22 Jan 2012', cal, 'modprevious'), datetime.datetime(2012, 1, 20)) # do not move non-holidays - self.assertEquals(busdayrule.rolldate('23 Jan 2012', cal, 'follow'), datetime.datetime(2012, 1, 23)) - self.assertEquals(busdayrule.rolldate('23 Jan 2012', cal, 'previous'), datetime.datetime(2012, 1, 23)) - self.assertEquals(busdayrule.rolldate('23 Jan 2012', cal, 'modfollow'), datetime.datetime(2012, 1, 23)) - self.assertEquals(busdayrule.rolldate('23 Jan 2012', cal, 'modprevious'), datetime.datetime(2012, 1, 23)) + self.assertEqual(busdayrule.rolldate('23 Jan 2012', cal, 'follow'), datetime.datetime(2012, 1, 23)) + self.assertEqual(busdayrule.rolldate('23 Jan 2012', cal, 'previous'), datetime.datetime(2012, 1, 23)) + self.assertEqual(busdayrule.rolldate('23 Jan 2012', cal, 'modfollow'), datetime.datetime(2012, 1, 23)) + self.assertEqual(busdayrule.rolldate('23 Jan 2012', cal, 'modprevious'), datetime.datetime(2012, 1, 23)) # EOM holidays - self.assertEquals(busdayrule.rolldate('1 Apr 2012', cal, 'follow'), datetime.datetime(2012, 4, 2)) - self.assertEquals(busdayrule.rolldate('1 Apr 2012', cal, 'previous'), datetime.datetime(2012, 3, 30)) - self.assertEquals(busdayrule.rolldate('1 Apr 2012', cal, 'modprevious'), datetime.datetime(2012, 4, 2)) - self.assertEquals(busdayrule.rolldate('30 Jun 2012', cal, 'modfollow'), datetime.datetime(2012, 6, 29)) - - self.assertEquals(busdayrule.lbusdate(2012, 6, cal), datetime.datetime(2012, 6, 29)) - self.assertEquals(busdayrule.lbusdate(2012, 1, cal), datetime.datetime(2012, 1, 31)) - self.assertEquals(busdayrule.fbusdate(2012, 1, cal), datetime.datetime(2012, 1, 3)) - self.assertEquals(busdayrule.fbusdate(2012, 4, cal), datetime.datetime(2012, 4, 2)) - self.assertEquals(busdayrule.fbusdate(2012, 2, cal), datetime.datetime(2012, 2, 1)) + self.assertEqual(busdayrule.rolldate('1 Apr 2012', cal, 'follow'), datetime.datetime(2012, 4, 2)) + self.assertEqual(busdayrule.rolldate('1 Apr 2012', cal, 'previous'), datetime.datetime(2012, 3, 30)) + self.assertEqual(busdayrule.rolldate('1 Apr 2012', cal, 'modprevious'), datetime.datetime(2012, 4, 2)) + self.assertEqual(busdayrule.rolldate('30 Jun 2012', cal, 'modfollow'), datetime.datetime(2012, 6, 29)) + + self.assertEqual(busdayrule.lbusdate(2012, 6, cal), datetime.datetime(2012, 6, 29)) + self.assertEqual(busdayrule.lbusdate(2012, 1, cal), datetime.datetime(2012, 1, 31)) + self.assertEqual(busdayrule.fbusdate(2012, 1, cal), datetime.datetime(2012, 1, 3)) + self.assertEqual(busdayrule.fbusdate(2012, 4, cal), datetime.datetime(2012, 4, 2)) + self.assertEqual(busdayrule.fbusdate(2012, 2, cal), datetime.datetime(2012, 2, 1)) class DaycountTestCase(unittest.TestCase): def test_daycount_actact(self): - self.assertEquals(daydiff('1 Dec 2002', '2 Dec 2002', 'actual/actual'), 1) - self.assertEquals(daydiff('1 Dec 2002', '31 Dec 2002', 'actual/actual'), 30) - self.assertEquals(daydiff('1 Jan 2002', '1 Jan 2003', 'actual/actual'), 365) - self.assertEquals(daydiff('1 Jan 2004', '1 Jan 2005', 'actual/actual'), 366) - self.assertEquals(daydiff('1 Jan 2004', '1 Jan 2006', 'actual/actual'), 731) - self.assertEquals(yearfrac('1 Jan 2004', '1 Jan 2005', 'actual/actual'), 1.0) - self.assertEquals(yearfrac('1 Jan 2003', '1 Jan 2004', 'actual/actual'), 1.0) + self.assertEqual(daydiff('1 Dec 2002', '2 Dec 2002', 'actual/actual'), 1) + self.assertEqual(daydiff('1 Dec 2002', '31 Dec 2002', 'actual/actual'), 30) + self.assertEqual(daydiff('1 Jan 2002', '1 Jan 2003', 'actual/actual'), 365) + self.assertEqual(daydiff('1 Jan 2004', '1 Jan 2005', 'actual/actual'), 366) + self.assertEqual(daydiff('1 Jan 2004', '1 Jan 2006', 'actual/actual'), 731) + self.assertEqual(yearfrac('1 Jan 2004', '1 Jan 2005', 'actual/actual'), 1.0) + self.assertEqual(yearfrac('1 Jan 2003', '1 Jan 2004', 'actual/actual'), 1.0) def test_daycount_act365fixed(self): - self.assertEquals(daydiff('1 Dec 2002', '2 Dec 2002', 'actual/365 fixed'), 1) - self.assertEquals(daydiff('1 Dec 2002', '31 Dec 2002', 'actual/365 fixed'), 30) - self.assertEquals(daydiff('1 Jan 2002', '1 Jan 2003', 'actual/365 fixed'), 365) - self.assertEquals(daydiff('1 Jan 2004', '1 Jan 2005', 'actual/365 fixed'), 366) - self.assertEquals(daydiff('1 Jan 2004', '1 Jan 2006', 'actual/365 fixed'), 731) + self.assertEqual(daydiff('1 Dec 2002', '2 Dec 2002', 'actual/365 fixed'), 1) + self.assertEqual(daydiff('1 Dec 2002', '31 Dec 2002', 'actual/365 fixed'), 30) + self.assertEqual(daydiff('1 Jan 2002', '1 Jan 2003', 'actual/365 fixed'), 365) + self.assertEqual(daydiff('1 Jan 2004', '1 Jan 2005', 'actual/365 fixed'), 366) + self.assertEqual(daydiff('1 Jan 2004', '1 Jan 2006', 'actual/365 fixed'), 731) self.assertGreater(yearfrac('1 Jan 2004', '1 Jan 2005', 'actual/365 fixed'), 1.0) - self.assertEquals(yearfrac('1 Jan 2003', '1 Jan 2004', 'actual/365 fixed'), 1.0) + self.assertEqual(yearfrac('1 Jan 2003', '1 Jan 2004', 'actual/365 fixed'), 1.0) def test_daycount_act365L(self): - self.assertEquals(daydiff('1 Dec 2002', '2 Dec 2002', 'actual/365L'), 1) - self.assertEquals(daydiff('1 Dec 2002', '31 Dec 2002', 'actual/365L'), 30) - self.assertEquals(daydiff('1 Jan 2002', '1 Jan 2003', 'actual/365L'), 365) - self.assertEquals(daydiff('1 Jan 2004', '1 Jan 2005', 'actual/365L'), 366) - self.assertEquals(daydiff('1 Jan 2004', '1 Jan 2006', 'actual/365L'), 731) + self.assertEqual(daydiff('1 Dec 2002', '2 Dec 2002', 'actual/365L'), 1) + self.assertEqual(daydiff('1 Dec 2002', '31 Dec 2002', 'actual/365L'), 30) + self.assertEqual(daydiff('1 Jan 2002', '1 Jan 2003', 'actual/365L'), 365) + self.assertEqual(daydiff('1 Jan 2004', '1 Jan 2005', 'actual/365L'), 366) + self.assertEqual(daydiff('1 Jan 2004', '1 Jan 2006', 'actual/365L'), 731) # 2004 is leap year so according to 365L plain, so we weill have 366 days # but denominator will be 365 self.assertGreater(yearfrac('1 Jan 2004', '1 Jan 2005', 'actual/365L'), 1.0) # 2004 is leap year so according to 365L plain, we take denominator as 366 self.assertLess(yearfrac('1 Jan 2003', '1 Jan 2004', 'actual/365L'), 1.0) # however if frequency is set to 'yearly', this works only if 29 feb is in the date rance - self.assertEquals(yearfrac('1 Jan 2003', '1 Jan 2004', 'actual/365L', frequency='yearly'), 1.0) + self.assertEqual(yearfrac('1 Jan 2003', '1 Jan 2004', 'actual/365L', frequency='yearly'), 1.0) # between two non-leap years it is just 1.0 - self.assertEquals(yearfrac('1 Jan 2002', '1 Jan 2003', 'actual/365L'), 1.0) + self.assertEqual(yearfrac('1 Jan 2002', '1 Jan 2003', 'actual/365L'), 1.0) def test_daycount_actact_afb(self): - self.assertEquals(daydiff('1 Dec 2002', '2 Dec 2002', 'actual/actual afb'), 1) - self.assertEquals(daydiff('1 Dec 2002', '31 Dec 2002', 'actual/actual afb'), 30) - self.assertEquals(daydiff('1 Jan 2002', '1 Jan 2003', 'actual/actual afb'), 365) - self.assertEquals(daydiff('1 Jan 2004', '1 Jan 2005', 'actual/actual afb'), 366) - self.assertEquals(daydiff('1 Jan 2004', '1 Jan 2006', 'actual/actual afb'), 731) - - self.assertEquals(yearfrac('1 Jan 2004', '1 Jan 2005', 'actual/actual afb'), 1.0) - self.assertEquals(yearfrac('1 Jan 2003', '1 Jan 2004', 'actual/actual afb'), 1.0) - self.assertEquals(yearfrac('1 Jan 2003', '1 Jan 2004', 'actual/actual afb'), 1.0) + self.assertEqual(daydiff('1 Dec 2002', '2 Dec 2002', 'actual/actual afb'), 1) + self.assertEqual(daydiff('1 Dec 2002', '31 Dec 2002', 'actual/actual afb'), 30) + self.assertEqual(daydiff('1 Jan 2002', '1 Jan 2003', 'actual/actual afb'), 365) + self.assertEqual(daydiff('1 Jan 2004', '1 Jan 2005', 'actual/actual afb'), 366) + self.assertEqual(daydiff('1 Jan 2004', '1 Jan 2006', 'actual/actual afb'), 731) + + self.assertEqual(yearfrac('1 Jan 2004', '1 Jan 2005', 'actual/actual afb'), 1.0) + self.assertEqual(yearfrac('1 Jan 2003', '1 Jan 2004', 'actual/actual afb'), 1.0) + self.assertEqual(yearfrac('1 Jan 2003', '1 Jan 2004', 'actual/actual afb'), 1.0) # 28/365 < 29/366 self.assertLess(yearfrac('1 Feb 2003', '1 Mar 2003', 'actual/actual afb'), yearfrac('1 Feb 2004', '1 Mar 2004', 'actual/actual afb')) def test_daycount_act360fixed(self): - self.assertEquals(daydiff('1 Dec 2002', '2 Dec 2002', 'actual/360'), 1) - self.assertEquals(daydiff('1 Dec 2002', '31 Dec 2002', 'actual/360'), 30) - self.assertEquals(daydiff('1 Jan 2002', '1 Jan 2003', 'actual/360'), 365) - self.assertEquals(daydiff('1 Jan 2004', '1 Jan 2005', 'actual/360'), 366) - self.assertEquals(daydiff('1 Jan 2004', '1 Jan 2006', 'actual/360'), 731) + self.assertEqual(daydiff('1 Dec 2002', '2 Dec 2002', 'actual/360'), 1) + self.assertEqual(daydiff('1 Dec 2002', '31 Dec 2002', 'actual/360'), 30) + self.assertEqual(daydiff('1 Jan 2002', '1 Jan 2003', 'actual/360'), 365) + self.assertEqual(daydiff('1 Jan 2004', '1 Jan 2005', 'actual/360'), 366) + self.assertEqual(daydiff('1 Jan 2004', '1 Jan 2006', 'actual/360'), 731) self.assertGreater(yearfrac('1 Jan 2004', '1 Jan 2005', 'actual/360'), 1.0) self.assertGreater(yearfrac('1 Jan 2003', '1 Jan 2004', 'actual/360'), 1.0) def test_daycount_30e360(self): - self.assertEquals(daydiff('1 Dec 2002', '31 Dec 2002', '30e/360'), 29) + self.assertEqual(daydiff('1 Dec 2002', '31 Dec 2002', '30e/360'), 29) # difference between two end-of months (neither of which is February) in 30e/360 is 30 - self.assertEquals(daydiff('30 Nov 2002', '31 Dec 2002', '30e/360'), 30) - self.assertEquals(daydiff('31 Aug 2002', '30 Sep 2002', '30e/360'), 30) - - self.assertEquals(daydiff('28 Feb 2002', '31 Mar 2002', '30e/360'), 32) - self.assertEquals(daydiff('29 Feb 2004', '31 Mar 2004', '30e/360'), 31) - self.assertEquals(daydiff('31 Jan 2002', '28 Feb 2002', '30e/360'), 28) - self.assertEquals(daydiff('31 Jan 2004', '29 Feb 2004', '30e/360'), 29) + self.assertEqual(daydiff('30 Nov 2002', '31 Dec 2002', '30e/360'), 30) + self.assertEqual(daydiff('31 Aug 2002', '30 Sep 2002', '30e/360'), 30) + + self.assertEqual(daydiff('28 Feb 2002', '31 Mar 2002', '30e/360'), 32) + self.assertEqual(daydiff('29 Feb 2004', '31 Mar 2004', '30e/360'), 31) + self.assertEqual(daydiff('31 Jan 2002', '28 Feb 2002', '30e/360'), 28) + self.assertEqual(daydiff('31 Jan 2004', '29 Feb 2004', '30e/360'), 29) def test_daycount_30360us(self): - self.assertEquals(daydiff('1 Dec 2002', '31 Dec 2002', '30/360 us'), 30) - # difference between two end-of months (neither of which is February) - self.assertEquals(daydiff('30 Nov 2002', '31 Dec 2002', '30/360 us'), 30) - self.assertEquals(daydiff('31 Aug 2002', '30 Sep 2002', '30/360 us'), 30) - - self.assertEquals(daydiff('28 Feb 2002', '31 Mar 2002', '30/360 us'), 33) - self.assertEquals(daydiff('29 Feb 2004', '31 Mar 2004', '30/360 us'), 32) - self.assertEquals(daydiff('31 Jan 2002', '28 Feb 2002', '30/360 us'), 28) - self.assertEquals(daydiff('31 Jan 2004', '29 Feb 2004', '30/360 us'), 29) + self.assertEqual(daydiff('1 Dec 2002', '31 Dec 2002', '30/360 us'), 30) + # difference between two end-of months (neither of which is February) + self.assertEqual(daydiff('30 Nov 2002', '31 Dec 2002', '30/360 us'), 30) + self.assertEqual(daydiff('31 Aug 2002', '30 Sep 2002', '30/360 us'), 30) + + self.assertEqual(daydiff('28 Feb 2002', '31 Mar 2002', '30/360 us'), 33) + self.assertEqual(daydiff('29 Feb 2004', '31 Mar 2004', '30/360 us'), 32) + self.assertEqual(daydiff('31 Jan 2002', '28 Feb 2002', '30/360 us'), 28) + self.assertEqual(daydiff('31 Jan 2004', '29 Feb 2004', '30/360 us'), 29) def test_daycount_30360us_eom(self): - self.assertEquals(daydiff('1 Dec 2002', '31 Dec 2002', '30/360 us', eom=True), 30) - # difference between two end-of months (neither of which is February) - self.assertEquals(daydiff('30 Nov 2002', '31 Dec 2002', '30/360 us', eom=True), 30) - self.assertEquals(daydiff('31 Aug 2002', '30 Sep 2002', '30/360 us', eom=True), 30) - - self.assertEquals(daydiff('28 Feb 2002', '31 Mar 2002', '30/360 us', eom=True), 30)RefactoringTool: Refactored ./findates/daycount.py RefactoringTool: Refactored ./findates/holidays.py RefactoringTool: No changes to ./setup.py RefactoringTool: Files that were modified: RefactoringTool: ./findates/busdayrule.py RefactoringTool: ./findates/dateutils.py RefactoringTool: ./findates/__init__.py RefactoringTool: ./findates/test/test_findates.py RefactoringTool: ./findates/daycount.py RefactoringTool: ./findates/holidays.py RefactoringTool: ./setup.py - self.assertEquals(daydiff('29 Feb 2004', '31 Mar 2004', '30/360 us', eom=True), 30) - self.assertEquals(daydiff('31 Jan 2002', '28 Feb 2002', '30/360 us', eom=True), 28) - self.assertEquals(daydiff('31 Jan 2004', '29 Feb 2004', '30/360 us', eom=True), 29) - - self.assertEquals(daydiff('29 Feb 2004', '28 Feb 2005', '30/360 us', eom=True), 360) - self.assertEquals(daydiff('28 Feb 2003', '29 Feb 2004', '30/360 us', eom=True), 360) - self.assertEquals(daydiff('28 Feb 2003', '28 Feb 2004', '30/360 us', eom=True), 358) + self.assertEqual(daydiff('1 Dec 2002', '31 Dec 2002', '30/360 us', eom=True), 30) + # difference between two end-of months (neither of which is February) + self.assertEqual(daydiff('30 Nov 2002', '31 Dec 2002', '30/360 us', eom=True), 30) + self.assertEqual(daydiff('31 Aug 2002', '30 Sep 2002', '30/360 us', eom=True), 30) + + self.assertEqual(daydiff('28 Feb 2002', '31 Mar 2002', '30/360 us', eom=True), 30) + self.assertEqual(daydiff('29 Feb 2004', '31 Mar 2004', '30/360 us', eom=True), 30) + self.assertEqual(daydiff('31 Jan 2002', '28 Feb 2002', '30/360 us', eom=True), 28) + self.assertEqual(daydiff('31 Jan 2004', '29 Feb 2004', '30/360 us', eom=True), 29) + + self.assertEqual(daydiff('29 Feb 2004', '28 Feb 2005', '30/360 us', eom=True), 360) + self.assertEqual(daydiff('28 Feb 2003', '29 Feb 2004', '30/360 us', eom=True), 360) + self.assertEqual(daydiff('28 Feb 2003', '28 Feb 2004', '30/360 us', eom=True), 358) def test_daycount_30e360isda(self): - self.assertEquals(daydiff('1 Dec 2002', '31 Dec 2002', '30e/360 isda'), 29) - # difference between two end-of months (neither of which is February) - self.assertEquals(daydiff('30 Nov 2002', '31 Dec 2002', '30e/360 isda'), 30) - self.assertEquals(daydiff('31 Aug 2002', '30 Sep 2002', '30e/360 isda'), 30) - - self.assertEquals(daydiff('28 Feb 2002', '31 Mar 2002', '30e/360 isda'), 30) - self.assertEquals(daydiff('29 Feb 2004', '31 Mar 2004', '30e/360 isda'), 30) - self.assertEquals(daydiff('31 Jan 2002', '28 Feb 2002', '30e/360 isda'), 28) - self.assertEquals(daydiff('31 Jan 2004', '29 Feb 2004', '30e/360 isda'), 29) + self.assertEqual(daydiff('1 Dec 2002', '31 Dec 2002', '30e/360 isda'), 29) + # difference between two end-of months (neither of which is February) + self.assertEqual(daydiff('30 Nov 2002', '31 Dec 2002', '30e/360 isda'), 30) + self.assertEqual(daydiff('31 Aug 2002', '30 Sep 2002', '30e/360 isda'), 30) + + self.assertEqual(daydiff('28 Feb 2002', '31 Mar 2002', '30e/360 isda'), 30) + self.assertEqual(daydiff('29 Feb 2004', '31 Mar 2004', '30e/360 isda'), 30) + self.assertEqual(daydiff('31 Jan 2002', '28 Feb 2002', '30e/360 isda'), 28) + self.assertEqual(daydiff('31 Jan 2004', '29 Feb 2004', '30e/360 isda'), 29) def test_daycount_30eplus360(self): - self.assertEquals(daydiff('1 Dec 2002', '31 Dec 2002', '30e+/360'), 30) - # difference between two end-of months (neither of which is February) - self.assertEquals(daydiff('30 Nov 2002', '31 Dec 2002', '30e+/360'), 31) - self.assertEquals(daydiff('31 Aug 2002', '30 Sep 2002', '30e+/360'), 30) - - self.assertEquals(daydiff('28 Feb 2002', '31 Mar 2002', '30e+/360'), 33) - self.assertEquals(daydiff('29 Feb 2004', '31 Mar 2004', '30e+/360'), 32) - self.assertEquals(daydiff('31 Jan 2002', '28 Feb 2002', '30e+/360'), 28) - self.assertEquals(daydiff('31 Jan 2004', '29 Feb 2004', '30e+/360'), 29) + self.assertEqual(daydiff('1 Dec 2002', '31 Dec 2002', '30e+/360'), 30) + # difference between two end-of months (neither of which is February) + self.assertEqual(daydiff('30 Nov 2002', '31 Dec 2002', '30e+/360'), 31) + self.assertEqual(daydiff('31 Aug 2002', '30 Sep 2002', '30e+/360'), 30) + + self.assertEqual(daydiff('28 Feb 2002', '31 Mar 2002', '30e+/360'), 33) + self.assertEqual(daydiff('29 Feb 2004', '31 Mar 2004', '30e+/360'), 32) + self.assertEqual(daydiff('31 Jan 2002', '28 Feb 2002', '30e+/360'), 28) + self.assertEqual(daydiff('31 Jan 2004', '29 Feb 2004', '30e+/360'), 29) if __name__ == "__main__": --- ./findates/daycount.py (original) +++ ./findates/daycount.py (refactored) @@ -3,7 +3,7 @@ # TODO # * refactor out alias lookup module -import dateutils +from . import dateutils _dc_norm = dict({ '30/360 US': '30/360 US', @@ -192,8 +192,8 @@ """ if not dates: return [] - dts = map(dateutils.asdatetime, dates) - return map(lambda x: yearfrac(dates[0], x, convention, **kwargs), dts) + dts = list(map(dateutils.asdatetime, dates)) + return [yearfrac(dates[0], x, convention, **kwargs) for x in dts] def daydiff(dt1, dt2, convention, **kwargs): """ Calculate difference in days between tow days according to a given --- ./findates/holidays.py (original) +++ ./findates/holidays.py (refactored) @@ -2,7 +2,7 @@ import collections import datetime -import dateutils +from . import dateutils class OrderMapper: @@ -39,8 +39,8 @@ abbreviated_day_names = [ 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun' ] month_names = ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] -month_name_order = OrderMapper(map(str.lower, month_names)) -weekday_name_order = OrderMapper(map(str.lower, day_names)) +month_name_order = OrderMapper(list(map(str.lower, month_names))) +weekday_name_order = OrderMapper(list(map(str.lower, day_names))) def easter(year): """ @@ -221,7 +221,7 @@ else: move = None # go through days of the week - if date_description.lower() in idiosyncratic_holidays.keys(): + if date_description.lower() in list(idiosyncratic_holidays.keys()): self._idiosyncratic[date_description.lower()] = (name, move) for day_name_idx in range(len(day_names)): day_name = day_names[day_name_idx] @@ -257,7 +257,7 @@ if not Y in self._idiosyncratic_years_cached: # compute idiosyncratic holidays for year Y id_table = dict() - for id in self._idiosyncratic.keys(): + for id in list(self._idiosyncratic.keys()): name, move = self._idiosyncratic[id] id_table[idiosyncratic_holidays[id](Y)] = (name, move) self._idiosyncratic_years_cached[Y] = id_table + RPM_EC=0 ++ jobs -p + exit 0 Executing(%build): /bin/sh -e /home/iurt/rpmbuild/tmp/rpm-tmp.9pJLzD + umask 022 + cd /home/iurt/rpmbuild/BUILD + cd FinDates-0.2 + '[' 1 -eq 1 ']' + '[' 1 -eq 1 ']' + CFLAGS='-O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fasynchronous-unwind-tables' + LDFLAGS=' -Wl,--as-needed -Wl,--no-undefined -Wl,-z,relro -Wl,-O1 -Wl,--build-id -Wl,--enable-new-dtags' + /usr/bin/python3 setup.py build '--executable=/usr/bin/python3 -s' running build running build_py creating build creating build/lib creating build/lib/findates copying findates/busdayrule.py -> build/lib/findates copying findates/dateutils.py -> build/lib/findates copying findates/__init__.py -> build/lib/findates copying findates/daycount.py -> build/lib/findates copying findates/holidays.py -> build/lib/findates creating build/lib/findates/test copying findates/test/test_findates.py -> build/lib/findates/test copying findates/test/__init__.py -> build/lib/findates/test + RPM_EC=0 ++ jobs -p + exit 0 Executing(%install): /bin/sh -e /home/iurt/rpmbuild/tmp/rpm-tmp.oAMKaF + umask 022 + cd /home/iurt/rpmbuild/BUILD + '[' 1 -eq 1 ']' + '[' /home/iurt/rpmbuild/BUILDROOT/python-findates-0.2-10.mga8.x86_64 '!=' / ']' + rm -rf /home/iurt/rpmbuild/BUILDROOT/python-findates-0.2-10.mga8.x86_64 ++ dirname /home/iurt/rpmbuild/BUILDROOT/python-findates-0.2-10.mga8.x86_64 + mkdir -p /home/iurt/rpmbuild/BUILDROOT + mkdir /home/iurt/rpmbuild/BUILDROOT/python-findates-0.2-10.mga8.x86_64 + cd FinDates-0.2 + '[' 1 -eq 1 ']' + /usr/bin/python3 setup.py install --skip-build --root /home/iurt/rpmbuild/BUILDROOT/python-findates-0.2-10.mga8.x86_64 running install running install_lib creating /home/iurt/rpmbuild/BUILDROOT/python-findates-0.2-10.mga8.x86_64/usr creating /home/iurt/rpmbuild/BUILDROOT/python-findates-0.2-10.mga8.x86_64/usr/lib creating /home/iurt/rpmbuild/BUILDROOT/python-findates-0.2-10.mga8.x86_64/usr/lib/python3.8 creating /home/iurt/rpmbuild/BUILDROOT/python-findates-0.2-10.mga8.x86_64/usr/lib/python3.8/site-packages creating /home/iurt/rpmbuild/BUILDROOT/python-findates-0.2-10.mga8.x86_64/usr/lib/python3.8/site-packages/findates copying build/lib/findates/busdayrule.py -> /home/iurt/rpmbuild/BUILDROOT/python-findates-0.2-10.mga8.x86_64/usr/lib/python3.8/site-packages/findates copying build/lib/findates/dateutils.py -> /home/iurt/rpmbuild/BUILDROOT/python-findates-0.2-10.mga8.x86_64/usr/lib/python3.8/site-packages/findates copying build/lib/findates/__init__.py -> /home/iurt/rpmbuild/BUILDROOT/python-findates-0.2-10.mga8.x86_64/usr/lib/python3.8/site-packages/findates creating /home/iurt/rpmbuild/BUILDROOT/python-findates-0.2-10.mga8.x86_64/usr/lib/python3.8/site-packages/findates/test copying build/lib/findates/test/test_findates.py -> /home/iurt/rpmbuild/BUILDROOT/python-findates-0.2-10.mga8.x86_64/usr/lib/python3.8/site-packages/findates/test copying build/lib/findates/test/__init__.py -> /home/iurt/rpmbuild/BUILDROOT/python-findates-0.2-10.mga8.x86_64/usr/lib/python3.8/site-packages/findates/test copying build/lib/findates/daycount.py -> /home/iurt/rpmbuild/BUILDROOT/python-findates-0.2-10.mga8.x86_64/usr/lib/python3.8/site-packages/findates copying build/lib/findates/holidays.py -> /home/iurt/rpmbuild/BUILDROOT/python-findates-0.2-10.mga8.x86_64/usr/lib/python3.8/site-packages/findates byte-compiling /home/iurt/rpmbuild/BUILDROOT/python-findates-0.2-10.mga8.x86_64/usr/lib/python3.8/site-packages/findates/busdayrule.py to busdayrule.cpython-38.pyc byte-compiling /home/iurt/rpmbuild/BUILDROOT/python-findates-0.2-10.mga8.x86_64/usr/lib/python3.8/site-packages/findates/dateutils.py to dateutils.cpython-38.pyc byte-compiling /home/iurt/rpmbuild/BUILDROOT/python-findates-0.2-10.mga8.x86_64/usr/lib/python3.8/site-packages/findates/__init__.py to __init__.cpython-38.pyc byte-compiling /home/iurt/rpmbuild/BUILDROOT/python-findates-0.2-10.mga8.x86_64/usr/lib/python3.8/site-packages/findates/test/test_findates.py to test_findates.cpython-38.pyc byte-compiling /home/iurt/rpmbuild/BUILDROOT/python-findates-0.2-10.mga8.x86_64/usr/lib/python3.8/site-packages/findates/test/__init__.py to __init__.cpython-38.pyc byte-compiling /home/iurt/rpmbuild/BUILDROOT/python-findates-0.2-10.mga8.x86_64/usr/lib/python3.8/site-packages/findates/daycount.py to daycount.cpython-38.pyc byte-compiling /home/iurt/rpmbuild/BUILDROOT/python-findates-0.2-10.mga8.x86_64/usr/lib/python3.8/site-packages/findates/holidays.py to holidays.cpython-38.pyc running install_egg_info Writing /home/iurt/rpmbuild/BUILDROOT/python-findates-0.2-10.mga8.x86_64/usr/lib/python3.8/site-packages/FinDates-0.2-py3.8.egg-info + /usr/lib/rpm/find-debuginfo.sh -j96 --strict-build-id -m -i --build-id-seed 0.2-10.mga8 --unique-debug-suffix -0.2-10.mga8.x86_64 --unique-debug-src-base python-findates-0.2-10.mga8.x86_64 --run-dwz --dwz-low-mem-die-limit 10000000 --dwz-max-die-limit 110000000 -S debugsourcefiles.list /home/iurt/rpmbuild/BUILD/FinDates-0.2 + /usr/lib/rpm/check-buildroot + '[' -n '' ']' + /usr/share/spec-helper/clean_files + '[' -n '' ']' + /usr/share/spec-helper/compress_files .xz + '[' -n '' ']' + /usr/share/spec-helper/relink_symlinks + '[' -n '' ']' + /usr/share/spec-helper/clean_perl + '[' -n '' ']' + /usr/share/spec-helper/lib_symlinks + '[' -n '' ']' + /usr/share/spec-helper/gprintify + '[' -n '' ']' + /usr/share/spec-helper/fix_mo + '[' -n '' ']' + /usr/share/spec-helper/fix_pamd + '[' -n '' ']' + /usr/share/spec-helper/remove_info_dir + '[' -n '' ']' + /usr/share/spec-helper/fix_eol + '[' -n '' ']' + /usr/share/spec-helper/check_desktop_files + '[' -n '' ']' + /usr/share/spec-helper/check_elf_files + /usr/lib/rpm/brp-python-bytecompile /usr/bin/python3 1 1 Bytecompiling .py files below /home/iurt/rpmbuild/BUILDROOT/python-findates-0.2-10.mga8.x86_64/usr/lib/python3.8 using /usr/bin/python3.8 + /usr/lib/rpm/brp-python-hardlink + /usr/lib/rpm/redhat/brp-mangle-shebangs Processing files: python3-findates-0.2-10.mga8.noarch Executing(%doc): /bin/sh -e /home/iurt/rpmbuild/tmp/rpm-tmp.YQd6nF + umask 022 + cd /home/iurt/rpmbuild/BUILD + cd FinDates-0.2 + DOCDIR=/home/iurt/rpmbuild/BUILDROOT/python-findates-0.2-10.mga8.x86_64/usr/share/doc/python3-findates + export LC_ALL=C + LC_ALL=C + export DOCDIR + /usr/bin/mkdir -p /home/iurt/rpmbuild/BUILDROOT/python-findates-0.2-10.mga8.x86_64/usr/share/doc/python3-findates + cp -pr README.txt /home/iurt/rpmbuild/BUILDROOT/python-findates-0.2-10.mga8.x86_64/usr/share/doc/python3-findates + RPM_EC=0 ++ jobs -p + exit 0 Provides: python-findates = 0.2-10.mga8 python3-findates = 0.2-10.mga8 python3.8-findates = 0.2-10.mga8 python3.8dist(findates) = 0.2 python3dist(findates) = 0.2 Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PartialHardlinkSets) <= 4.0.4-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1 Requires: python(abi) = 3.8 Checking for unpackaged file(s): /usr/lib/rpm/check-files /home/iurt/rpmbuild/BUILDROOT/python-findates-0.2-10.mga8.x86_64 Wrote: /home/iurt/rpmbuild/RPMS/noarch/python3-findates-0.2-10.mga8.noarch.rpm Executing(%clean): /bin/sh -e /home/iurt/rpmbuild/tmp/rpm-tmp.QLV2xE + umask 022 + cd /home/iurt/rpmbuild/BUILD + cd FinDates-0.2 + /usr/bin/rm -rf /home/iurt/rpmbuild/BUILDROOT/python-findates-0.2-10.mga8.x86_64 + RPM_EC=0 ++ jobs -p + exit 0 Executing(--clean): /bin/sh -e /home/iurt/rpmbuild/tmp/rpm-tmp.pqnKPC + umask 022 + cd /home/iurt/rpmbuild/BUILD + rm -rf FinDates-0.2 + RPM_EC=0 ++ jobs -p + exit 0 D: [iurt_root_command] Success!