devtools/testlib.py
changeset 5385 b6e250dd7a7d
parent 5274 16461f675734
parent 5377 84d14ddfae13
child 5408 120db445c179
equal deleted inserted replaced
5382:cb5dfea92285 5385:b6e250dd7a7d
    15 from urllib import unquote
    15 from urllib import unquote
    16 from math import log
    16 from math import log
    17 from contextlib import contextmanager
    17 from contextlib import contextmanager
    18 from warnings import warn
    18 from warnings import warn
    19 
    19 
    20 import simplejson
    20 try:
       
    21     import json
       
    22 except ImportError:
       
    23     import simplejson as json
    21 
    24 
    22 import yams.schema
    25 import yams.schema
    23 
    26 
    24 from logilab.common.testlib import TestCase, InnerTest
    27 from logilab.common.testlib import TestCase, InnerTest
    25 from logilab.common.pytest import nocoverage, pause_tracing, resume_tracing
    28 from logilab.common.pytest import nocoverage, pause_tracing, resume_tracing
   486         req.set_session(self.websession)
   489         req.set_session(self.websession)
   487         return req
   490         return req
   488 
   491 
   489     def remote_call(self, fname, *args):
   492     def remote_call(self, fname, *args):
   490         """remote json call simulation"""
   493         """remote json call simulation"""
   491         dump = simplejson.dumps
   494         dump = json.dumps
   492         args = [dump(arg) for arg in args]
   495         args = [dump(arg) for arg in args]
   493         req = self.request(fname=fname, pageid='123', arg=args)
   496         req = self.request(fname=fname, pageid='123', arg=args)
   494         ctrl = self.vreg['controllers'].select('json', req)
   497         ctrl = self.vreg['controllers'].select('json', req)
   495         return ctrl.publish(), req
   498         return ctrl.publish(), req
   496 
   499