diff options
-rw-r--r-- | setup.cfg | 2 | ||||
-rw-r--r-- | setup.py | 3 | ||||
-rw-r--r-- | src/isodate/duration.py | 5 | ||||
-rw-r--r-- | src/isodate/tests/test_duration.py | 4 | ||||
-rw-r--r-- | src/isodate/tests/test_pickle.py | 6 | ||||
-rw-r--r-- | src/isodate/tzinfo.py | 15 | ||||
-rw-r--r-- | tox.ini | 2 |
7 files changed, 31 insertions, 6 deletions
@@ -1,2 +1,2 @@ [bdist_wheel] -universal=1 +universal = 1 @@ -50,7 +50,7 @@ setup(name='isodate', description='An ISO 8601 date/time/duration parser and formatter', license='BSD', # keywords = '', - url='http://cheeseshop.python.org/pypi/isodate', + url='https://github.com/gweis/isodate/', long_description=(read('README.rst') + read('CHANGES.txt') + @@ -63,7 +63,6 @@ setup(name='isodate', 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3.2', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', diff --git a/src/isodate/duration.py b/src/isodate/duration.py index 5408315..a215aa0 100644 --- a/src/isodate/duration.py +++ b/src/isodate/duration.py @@ -121,7 +121,10 @@ class Duration(object): if self.years: params.append('%d years' % self.years) if self.months: - params.append('%d months' % self.months) + fmt = "%d months" + if self.months <= 1: + fmt = "%d month" + params.append(fmt % self.months) params.append(str(self.tdelta)) return ', '.join(params) diff --git a/src/isodate/tests/test_duration.py b/src/isodate/tests/test_duration.py index c03ae74..b0e0332 100644 --- a/src/isodate/tests/test_duration.py +++ b/src/isodate/tests/test_duration.py @@ -313,6 +313,10 @@ class DurationTest(unittest.TestCase): self.assertEqual('10 years, 10 months, 10 days, 0:00:10', str(dur)) self.assertEqual('isodate.duration.Duration(10, 10, 0,' ' years=10, months=10)', repr(dur)) + dur = Duration(months=0) + self.assertEqual('0:00:00', str(dur)) + dur = Duration(months=1) + self.assertEqual('1 month, 0:00:00', str(dur)) def test_hash(self): ''' diff --git a/src/isodate/tests/test_pickle.py b/src/isodate/tests/test_pickle.py index 46bf34d..0d8c184 100644 --- a/src/isodate/tests/test_pickle.py +++ b/src/isodate/tests/test_pickle.py @@ -39,6 +39,12 @@ class TestPickle(unittest.TestCase): self.assertEqual(len(failed), 0, "pickle protos failed: %s" % str(failed)) + def test_pickle_utc(self): + ''' + isodate.UTC objects remain the same after pickling. + ''' + self.assertTrue(isodate.UTC is pickle.loads(pickle.dumps(isodate.UTC))) + def test_suite(): ''' diff --git a/src/isodate/tzinfo.py b/src/isodate/tzinfo.py index 83b241c..5d3a42d 100644 --- a/src/isodate/tzinfo.py +++ b/src/isodate/tzinfo.py @@ -36,11 +36,24 @@ class Utc(tzinfo): ''' return ZERO + def __reduce__(self): + ''' + When unpickling a Utc object, return the default instance below, UTC. + ''' + return _Utc, () + UTC = Utc() # the default instance for UTC. +def _Utc(): + ''' + Helper function for unpickling a Utc object. + ''' + return UTC + + class FixedOffset(tzinfo): ''' A class building tzinfo objects for fixed-offset time zones. @@ -140,5 +153,5 @@ class LocalTimezone(tzinfo): return tt.tm_isdst > 0 -LOCAL = LocalTimezone() # the default instance for local time zone. +LOCAL = LocalTimezone() @@ -1,5 +1,5 @@ [tox] -envlist = py26,py27,py32,py33,py34,pypy,pypy3,flake,cover +envlist = py26,py27,py33,py34,pypy,pypy3,flake,cover [testenv] deps = |