Fix failing test

This commit is contained in:
Kovid Goyal 2018-04-13 10:01:42 +05:30
parent 39032f5b5e
commit 0234d75aa2
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 8 additions and 5 deletions

View File

@ -175,11 +175,13 @@ class TestOPF3(unittest.TestCase):
from calibre.utils.date import utcnow
def rl(root):
return read_pubdate(root, read_prefixes(root), read_refines(root)), read_timestamp(root, read_prefixes(root), read_refines(root))
p, r = read_prefixes(root), read_refines(root)
return read_pubdate(root, p, r), read_timestamp(root, p, r)
def st(root, pd, ts):
set_pubdate(root, read_prefixes(root), read_refines(root), pd)
set_timestamp(root, read_prefixes(root), read_refines(root), ts)
p, r = read_prefixes(root), read_refines(root)
set_pubdate(root, p, r, pd)
set_timestamp(root, p, r, ts)
return rl(root)
def ae(root, y1=None, y2=None):
@ -192,7 +194,8 @@ class TestOPF3(unittest.TestCase):
root = self.get_opf('''<dc:date>1999-3-2</dc:date><meta property="calibre:timestamp" scheme="dcterms:W3CDTF">2001</meta>''')
ae(root, 1999, 2001)
n = utcnow()
self.ae(st(root, n, n), (n, n))
q = n.replace(microsecond=0)
self.ae(st(root, n, n), (n, q))
root = self.get_opf('''<dc:date>1999-3-2</dc:date><meta name="calibre:timestamp" content="2001-1-1"/>''')
ae(root, 1999, 2001)
root = self.get_opf('''<meta property="dcterms:modified">2003</meta>''')

View File

@ -199,7 +199,7 @@ def w3cdtf(date_time, assume_utc=False):
date_time = date_time.replace(tzinfo=_utc_tz if assume_utc else
_local_tz)
date_time = date_time.astimezone(_utc_tz if as_utc else _local_tz)
return unicode(date_time.strftime('%Y-%M-%dT%H:%M:%SZ'))
return unicode(date_time.strftime('%Y-%m-%dT%H:%M:%SZ'))
def as_local_time(date_time, assume_utc=True):