1. desmaj
  2. orbited

Commits

desmaj  committed 4e9043d

cleaned up json library selection a bit; removed some stray and deadly imports from the functional test modules; added a pip requirement file that requires libraries you'd use for development

  • Participants
  • Parent commits 6e007f7
  • Branches TRAC-150

Comments (0)

Files changed (6)

File daemon/development.req

View file
+nose
+objgraph
+simplejson

File daemon/orbited/json.py

View file
 Select a JSON library from any of several known libraries.
 """
 
-try:
-    import cjson
-    encode = cjson.encode
-    decode = cjson.decode
-except ImportError:
+modules = [('json', 'dumps', 'loads'), 
+           ('cjson', 'encode', 'decode'), 
+           ('simplejson', 'dumps', 'loads'),
+           ('demjson', 'encode', 'decode'),
+          ]
+
+while modules:
+    module_name, serializer, deserializer = modules.pop(0)
     try:
-        import simplejson
-        encode = simplejson.dumps
-        decode = simplejson.loads
+        json = __import__(module_name)
+        encode = getattr(json, serializer)
+        decode = getattr(json, deserializer)
+        break
     except ImportError:
-        try:
-            import demjson
-            encode = demjson.encode
-            decode = demjson.decode
-        except ImportError:
-            raise ImportError, "could not load one of: cjson, simplejson, demjson"
-        
+        if not modules:
+            raise ImportError,\
+                "could not load one of: json, cjson, simplejson, demjson"
+

File daemon/orbited/test/functional/test_cross_port_tcp_socket.py

View file
-from selenium import selenium
-import time, re
-
 from orbited.test.functional import TCPSocketTestCase
 
 class TestCrossPortTCPSocket(TCPSocketTestCase):

File daemon/orbited/test/functional/test_cross_subdomain_tcp_socket.py

View file
-from selenium import selenium
-import time, re
-
 from orbited.test.functional import TCPSocketTestCase
 
 class TestCrossSubdomainTCPSocket(TCPSocketTestCase):

File daemon/orbited/test/functional/test_same_domain_tcp_socket.py

View file
-from selenium import selenium
-import time, re
-
 from orbited.test.functional import TCPSocketTestCase
 
 class TestSameDomainTCPSocket(TCPSocketTestCase):

File daemon/orbited/test/resources/__init__.py

Empty file added.