Fixed that ValueError was not raised

This commit is contained in:
Lars Kiesow 2013-05-14 17:53:18 +02:00
parent 3044c782e5
commit f47783cfb0
2 changed files with 10 additions and 10 deletions

View file

@ -256,9 +256,9 @@ class FeedEntry(object):
if isinstance(updated, basestring): if isinstance(updated, basestring):
updated = dateutil.parser.parse(updated) updated = dateutil.parser.parse(updated)
if not isinstance(updated, datetime): if not isinstance(updated, datetime):
ValueError('Invalid datetime format') raise ValueError('Invalid datetime format')
if updated.tzinfo is None: if updated.tzinfo is None:
ValueError('Datetime object has no timezone info') raise ValueError('Datetime object has no timezone info')
self.__atom_updated = updated self.__atom_updated = updated
self.__rss_lastBuildDate = updated self.__rss_lastBuildDate = updated
@ -518,9 +518,9 @@ class FeedEntry(object):
if isinstance(published, basestring): if isinstance(published, basestring):
published = dateutil.parser.parse(published) published = dateutil.parser.parse(published)
if not isinstance(published, datetime): if not isinstance(published, datetime):
ValueError('Invalid datetime format') raise ValueError('Invalid datetime format')
if published.tzinfo is None: if published.tzinfo is None:
ValueError('Datetime object has no timezone info') raise ValueError('Datetime object has no timezone info')
self.__atom_published = published self.__atom_published = published
self.__rss_pubDate = published self.__rss_pubDate = published

View file

@ -405,9 +405,9 @@ class FeedGenerator(object):
if isinstance(updated, basestring): if isinstance(updated, basestring):
updated = dateutil.parser.parse(updated) updated = dateutil.parser.parse(updated)
if not isinstance(updated, datetime.datetime): if not isinstance(updated, datetime.datetime):
ValueError('Invalid datetime format') raise ValueError('Invalid datetime format')
if updated.tzinfo is None: if updated.tzinfo is None:
ValueError('Datetime object has no timezone info') raise ValueError('Datetime object has no timezone info')
self.__atom_updated = updated self.__atom_updated = updated
self.__rss_lastBuildDate = updated self.__rss_lastBuildDate = updated
@ -820,9 +820,9 @@ class FeedGenerator(object):
if isinstance(pubDate, basestring): if isinstance(pubDate, basestring):
pubDate = dateutil.parser.parse(pubDate) pubDate = dateutil.parser.parse(pubDate)
if not isinstance(pubDate, datetime.datetime): if not isinstance(pubDate, datetime.datetime):
ValueError('Invalid datetime format') raise ValueError('Invalid datetime format')
if pubDate.tzinfo is None: if pubDate.tzinfo is None:
ValueError('Datetime object has no timezone info') raise ValueError('Datetime object has no timezone info')
self.__rss_pubDate = pubDate self.__rss_pubDate = pubDate
return self.__rss_pubDate return self.__rss_pubDate
@ -853,7 +853,7 @@ class FeedGenerator(object):
hours = [hours] hours = [hours]
for h in hours: for h in hours:
if not h in xrange(24): if not h in xrange(24):
ValueError('Invalid hour %s' % h) raise ValueError('Invalid hour %s' % h)
if replace or not self.__rss_skipHours: if replace or not self.__rss_skipHours:
self.__rss_skipHours = set() self.__rss_skipHours = set()
self.__rss_skipHours |= set(hours) self.__rss_skipHours |= set(hours)
@ -877,7 +877,7 @@ class FeedGenerator(object):
for d in days: for d in days:
if not d in ['Monday', 'Tuesday', 'Wednesday', 'Thursday', if not d in ['Monday', 'Tuesday', 'Wednesday', 'Thursday',
'Friday', 'Saturday', 'Sunday']: 'Friday', 'Saturday', 'Sunday']:
ValueError('Invalid day %s' % h) raise ValueError('Invalid day %s' % h)
if replace or not self.__rss_skipDays: if replace or not self.__rss_skipDays:
self.__rss_skipDays = set() self.__rss_skipDays = set()
self.__rss_skipDays |= set(days) self.__rss_skipDays |= set(days)