devtools/testlib.py
branchstable
changeset 5377 84d14ddfae13
parent 5268 b4bb59824d72
child 5385 b6e250dd7a7d
child 5389 809d3b5b3d31
equal deleted inserted replaced
5376:2c3f14bc2590 5377:84d14ddfae13
    12 import re
    12 import re
    13 from urllib import unquote
    13 from urllib import unquote
    14 from math import log
    14 from math import log
    15 from contextlib import contextmanager
    15 from contextlib import contextmanager
    16 
    16 
    17 import simplejson
    17 try:
       
    18     import json
       
    19 except ImportError:
       
    20     import simplejson as json
    18 
    21 
    19 import yams.schema
    22 import yams.schema
    20 
    23 
    21 from logilab.common.testlib import TestCase, InnerTest
    24 from logilab.common.testlib import TestCase, InnerTest
    22 from logilab.common.pytest import nocoverage, pause_tracing, resume_tracing
    25 from logilab.common.pytest import nocoverage, pause_tracing, resume_tracing
   481         req.set_connection(self.cnx)
   484         req.set_connection(self.cnx)
   482         return req
   485         return req
   483 
   486 
   484     def remote_call(self, fname, *args):
   487     def remote_call(self, fname, *args):
   485         """remote json call simulation"""
   488         """remote json call simulation"""
   486         dump = simplejson.dumps
   489         dump = json.dumps
   487         args = [dump(arg) for arg in args]
   490         args = [dump(arg) for arg in args]
   488         req = self.request(fname=fname, pageid='123', arg=args)
   491         req = self.request(fname=fname, pageid='123', arg=args)
   489         ctrl = self.vreg['controllers'].select('json', req)
   492         ctrl = self.vreg['controllers'].select('json', req)
   490         return ctrl.publish(), req
   493         return ctrl.publish(), req
   491 
   494