Currently fails on Sphinx doctests because the str() function of datetime.datetime is equivalent to calling .isoformat(' ') on it [1], which replaces the 'T' with a space. This results in an invalid timestamp.
For a truncated example:
File "examples.rst", line 513, in default
Failed example:
from cybox.objects.email_message_object import EmailMessage
e = EmailMessage()
e.date = "Mon, 14 Oct, 2013 12:32:03 -0500"
print(e.to_xml(include_namespaces=False, encoding=None))
Expected:
<EmailMessageObj:Date>2013-10-14T12:32:03-05:00</EmailMessageObj:Date>
Got:
<EmailMessageObj:Date>2013-10-14 12:32:03-05:00</EmailMessageObj:Date>
I'm not sure of the best place to put code to fix this, though. Maybe in cybox/utils/init.py, in normalize_to_xml() [2], we could check if value is instance of datetime.datetime and if so use value.isoformat() instead of text_type(value)?
Currently fails on Sphinx doctests because the str() function of datetime.datetime is equivalent to calling .isoformat(' ') on it [1], which replaces the 'T' with a space. This results in an invalid timestamp.
For a truncated example:
I'm not sure of the best place to put code to fix this, though. Maybe in cybox/utils/init.py, in normalize_to_xml() [2], we could check if value is instance of datetime.datetime and if so use value.isoformat() instead of text_type(value)?