Source code for tests.30_libs.040_PySourceInfo.getCallerModulePathName.CallCase

"""Check defaults.
"""
from __future__ import absolute_import

import unittest
import os

import pysourceinfo.PySourceInfo


#
#######################
#
[docs]class CallUnits(unittest.TestCase):
[docs] def testCase000(self): import sys _s=sys.path[:] sys.path.insert(0,os.path.dirname(__file__)+os.sep+'..') import PySourceInfo_check_tests #@UnresolvedImport fpn = pysourceinfo.PySourceInfo.getModulePathName(pysourceinfo.PySourceInfo) fx = PySourceInfo_check_tests.check_callback(pysourceinfo.PySourceInfo.getCallerModulePathName,0) [ sys.path.pop() for x in range(len(sys.path)) ] #@UnusedVariable sys.path.extend(_s) assert os.path.normpath(fx) == fpn
[docs] def testCase001(self): import sys _s=sys.path[:] sys.path.insert(0,os.path.dirname(__file__)+os.sep+'..') import PySourceInfo_check_tests #@UnresolvedImport fpn = pysourceinfo.PySourceInfo.getModulePathName(PySourceInfo_check_tests) fx = PySourceInfo_check_tests.check_callback(pysourceinfo.PySourceInfo.getCallerModulePathName,1) [ sys.path.pop() for x in range(len(sys.path)) ] #@UnusedVariable sys.path.extend(_s) assert os.path.normpath(fx) == fpn
[docs] def testCase002(self): import sys _s=sys.path[:] sys.path.insert(0,os.path.dirname(__file__)+os.sep+'..') import PySourceInfo_check_tests #@UnresolvedImport fpn = os.path.abspath(os.path.normpath(os.path.dirname(__file__))) fx = PySourceInfo_check_tests.check_callback(pysourceinfo.PySourceInfo.getCallerModulePathName,2) [ sys.path.pop() for x in range(len(sys.path)) ] #@UnusedVariable sys.path.extend(_s) assert os.path.normpath(fx) == fpn
[docs] def testCase003(self): import sys _s=sys.path[:] sys.path.insert(0,os.path.dirname(__file__)+os.sep+'..') import PySourceInfo_check_tests #@UnresolvedImport version = '{0}.{1}'.format(*sys.version_info[:2]) if version == '2.6': # pragma: no cover fx = PySourceInfo_check_tests.check_callback(pysourceinfo.PySourceInfo.getCallerModulePathName,3) [ sys.path.pop() for x in range(len(sys.path)) ] #@UnusedVariable sys.path.extend(_s) assert os.path.basename(fx) == 'python2.6' elif version == '2.7': # pragma: no cover fx = PySourceInfo_check_tests.check_callback(pysourceinfo.PySourceInfo.getCallerModulePathName,3) [ sys.path.pop() for x in range(len(sys.path)) ] #@UnusedVariable sys.path.extend(_s) assert os.path.basename(fx) == 'unittest' else: assert False
if __name__ == '__main__': unittest.main()