goa/test/pytestconf.py
changeset 4737 64143d458495
parent 4622 790181bfd19c
parent 4736 b7749ae9572f
child 4762 8dce25da9d95
equal deleted inserted replaced
4622:790181bfd19c 4737:64143d458495
     1 """this pytestconf automatically adds the mx's python version in the PYTHONPATH
       
     2 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
       
     3 """
       
     4 import sys
       
     5 import os.path as osp
       
     6 
       
     7 import cubicweb
       
     8 # remove 'mx' modules imported by cubicweb
       
     9 for modname in sys.modules.keys():
       
    10     if modname.startswith('mx'):
       
    11         sys.modules.pop(modname)
       
    12 
       
    13 # this is where mx should get imported from
       
    14 mxpath = osp.abspath(osp.join(osp.dirname(cubicweb.__file__), 'embedded'))
       
    15 sys.path.insert(1, mxpath)
       
    16 
       
    17 # make sure the correct mx is imported
       
    18 import mx
       
    19 assert osp.dirname(mx.__file__) == osp.join(mxpath, 'mx'), '%s != %s' % (osp.dirname(mx.__file__), mxpath)