Commits

Olemis Lang committed 3f79009

BH RPC : Bugs fixed: inspect.getmodule may return None.

Normalize test cases to deal with datetime.datetime (instead of xmlrpclib.DateTime)

Comments (0)

Files changed (2)

trunk/tracrpc/tests/_jsonrpclib.py

                                      ignore_attribute, ignore)
             return new_obj
     # It's not a standard type, so it needs __jsonclass__
-    module_name = inspect.getmodule(obj).__name__
+    module = inspect.getmodule(obj)
+    module_name = module.__name__ if module is not None else ''
     class_name = obj.__class__.__name__
     json_class = class_name
-    if module_name not in ['', '__main__']:
+    if module_name not in ('', '__main__'):
         json_class = '%s.%s' % (module_name, json_class)
     return_obj = {"__jsonclass__":[json_class,]}
     # If a serialization method is defined..

trunk/tracrpc/tests/ticket.py

         from tracrpc.xml_rpc import from_xmlrpc_datetime
         tid = self.admin.ticket.create('test_update_time_changed', '...', {})
         tid, created, modified, attrs = self.admin.ticket.get(tid)
-        then = from_xmlrpc_datetime(modified) - datetime.timedelta(minutes=1)
+        if isinstance(modified, xmlrpclib.DateTime):
+            # Most RPC protocols return instances of datetime , not XML-RPC
+            modified = from_xmlrpc_datetime(modified)
+        then = modified - datetime.timedelta(minutes=1)
         # Unrestricted old-style update (to be removed soon)
         try:
             self.admin.ticket.update(tid, "comment1",