Source code for UseCases.PySourceInfo.getCallerPathName.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.abspath(os.path.dirname(__file__)+os.sep+'..')) import PySourceInfo_check #@UnresolvedImport fpn = pysourceinfo.PySourceInfo.getModulePathName(pysourceinfo.PySourceInfo) fx = PySourceInfo_check.check_callback(pysourceinfo.PySourceInfo.getCallerPathName,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.abspath(os.path.dirname(__file__)+os.sep+'..')) import PySourceInfo_check #@UnresolvedImport fx0 = pysourceinfo.PySourceInfo.getModulePathName(PySourceInfo_check) fx1 = pysourceinfo.PySourceInfo.getModulePathName(pysourceinfo) # fx0 = PySourceInfo_check.__name__ # fx1 = "tests" # # fx = PySourceInfo_check.check_callback(pysourceinfo.PySourceInfo.getCallerPackageName,1) # # # due to PyUnit path resolution dependent on curdir # assert fx == fx0 or fx == fx1 fx = PySourceInfo_check.check_callback(pysourceinfo.PySourceInfo.getCallerPathName,1) fx = os.path.normpath(fx) [ sys.path.pop() for x in range(len(sys.path)) ] #@UnusedVariable sys.path.extend(_s) assert fx == fx0 or fx == fx1
[docs] def testCase003(self): import sys _s = sys.path[:] sys.path.insert(0,os.path.abspath(os.path.dirname(__file__)+os.sep+'..')) import PySourceInfo_check #@UnresolvedImport fx = PySourceInfo_check.check_callback(pysourceinfo.PySourceInfo.getCallerPathName,3) [ sys.path.pop() for x in range(len(sys.path)) ] #@UnusedVariable sys.path.extend(_s) version = '{0}.{1}'.format(*sys.version_info[:2]) if version == '2.6': # pragma: no cover assert os.path.basename(fx) == 'python2.6' elif version == '2.7': # pragma: no cover assert os.path.basename(fx) == 'unittest' else: assert False
if __name__ == '__main__': unittest.main()