Exemplo n.º 1
0
    def testCase000(self):

        slst = []
        setUpperTreeSearchPath(os.path.abspath(os.path.dirname(__file__)),
                               'epyunit', slst)

        epyu = findRelPathInSearchPath('bin/epyunit', slst, matchidx=0)
        scri = findRelPathInSearchPath('epyunit/myscript.sh', slst, matchidx=0)

        _call = epyu
        _call += " " + scri
        _call += " OK "

        syskargs = {}
        sx = epyunit.SystemCalls.SystemCalls(**syskargs)

        callkargs = {}
        ret = sx.callit(_call, **callkargs)

        assert ret == [
            0,
            [
                'fromA', 'arbitrary output', 'arbitrary signalling OK string',
                'arbitrary output'
            ],
            [],
        ]
        pass
Exemplo n.º 2
0
    def testCase000(self):

        slst = []
        setUpperTreeSearchPath(os.path.abspath(os.path.dirname(__file__)),
                               'epyunit', slst)
        myscript = findRelPathInSearchPath('epyunit/myscript.sh',
                                           slst,
                                           matchidx=0)

        sx = epyunit.SystemCalls.SystemCalls()

        #         _env = os.environ.copy()
        #         _env['PATH'] = os.pathsep.join(sys.path)

        ret = sx.callit(myscript + " EXIT8")

        assert ret[0] == 8
        assert ret[1] == [
            "fromG", 'arbitrary output', 'arbitrary signalling NOK string',
            'arbitrary output'
        ]
        assert ret[2] == [
            'arbitrary err output', 'arbitrary err signalling NOK string',
            'arbitrary err output'
        ]
        pass
Exemplo n.º 3
0
 def setUpClass(cls):
     cls.slst = []
     setUpperTreeSearchPath(os.path.abspath(os.path.dirname(__file__)),'epyunit',cls.slst)
     
     cls.epyu = epyu
     cls.scri = call_scripy
     cls.scri = cls.scri
Exemplo n.º 4
0
    def setUpClass(cls):
        slst = []
        setUpperTreeSearchPath(os.path.abspath(os.path.dirname(__file__)),'epyunit',slst)
        
        cls.epyu = findRelPathInSearchPath('bin/epyunit',slst,matchidx=0)
        cls.scri = findRelPathInSearchPath('epyunit/myscript.sh',slst,matchidx=0)

        cls.cache = True
Exemplo n.º 5
0
    def setUpClass(cls):
        slst = []
        setUpperTreeSearchPath(os.path.abspath(os.path.dirname(__file__)),'epyunit',slst)
        
        cls.epyu = findRelPathInSearchPath('bin/epyunit',slst,matchidx=0)
        cls.scri = findRelPathInSearchPath('epyunit/myscript.sh',slst,matchidx=0)

        cls.cache = True
Exemplo n.º 6
0
    def setUpClass(cls):
        cls.slst = []
        setUpperTreeSearchPath(os.path.abspath(os.path.dirname(__file__)),'epyunit',cls.slst)

        cls._call  = epyu
        cls._call += " --raw "
        cls._call += " --priotype=True "
        cls._call += " " + call_scripy
Exemplo n.º 7
0
    def setUpClass(cls):
        cls.slst = []
        setUpperTreeSearchPath(os.path.abspath(os.path.dirname(__file__)),'epyunit',cls.slst)
        
        cls.epyu = epyu
        cls.scri = call_scripy
        cls.scri = cls.scri

        cls.callkargs = {}
        cls.displayargs = {} 

        cls.displayargs['out'] = 'passall' 
        cls.displayargs['outtarget'] = 'str' 
Exemplo n.º 8
0
    def setUpClass(cls):
        cls.slst = []
        setUpperTreeSearchPath(os.path.abspath(os.path.dirname(__file__)),
                               'epyunit', cls.slst)

        cls.epyu = epyu
        cls.scri = call_scripy
        cls.scri = cls.scri

        cls.callkargs = {}
        cls.displayargs = {}

        cls.displayargs['out'] = 'passall'
        cls.displayargs['outtarget'] = 'str'
Exemplo n.º 9
0
    def testCase010(self):
        """The mdofied output by the option::

           --exitign=True

        original default output for case EXIT9OK3NOK2::

           EXIT:
              0
           STDOUT:
              fromH
              OK
              OK
              OK
           STDERR:
              NOK
              NOK

        """

        slst = []
        setUpperTreeSearchPath(os.path.abspath(os.path.dirname(__file__)),
                               'epyunit', slst)

        epyu = findRelPathInSearchPath('bin/epyunit', slst, matchidx=0)
        scri = findRelPathInSearchPath('epyunit/myscript.sh', slst, matchidx=0)

        _call = epyu
        #        _call += " --rdbg=127.0.0.1:5678 "
        _call += " --rdbg "
        #        _call += " --pass "
        #        _call += " --passall "
        #        _call += " --exitign=True "
        _call += " -- "
        _call += scri
        _call += " EXIT9OK3NOK2 "

        syskargs = {}

        #
        # make a simple system call, the actual unittest is processed within the subprocess
        #
        sx = epyunit.SystemCalls.SystemCalls(**syskargs)

        callkargs = {}
        ret = sx.callit(_call, **callkargs)

        assert ret == [1, ['fromH', 'OK', 'OK', 'OK'], ['NOK', 'NOK']]
        pass
Exemplo n.º 10
0
    def testCase000(self):
        _s = sys.path[:]
        #
        # set search for the call of 'myscript.sh'
        from filesysobjects.FileSysObjects import setUpperTreeSearchPath
        setUpperTreeSearchPath(os.path.abspath(os.path.dirname(__file__)),'pyfilesysobjects')
        from tests.dummymodules.Dummy0 import Dummy0
        
        d = Dummy0()
        d.set(1)

        [ sys.path.pop() for x in range(len(sys.path)) ] #@UnusedVariable
        sys.path.extend(_s)
        
        pass
Exemplo n.º 11
0
    def testCase010(self):
        """The mdofied output by the option::

           --exitign=True

        original default output for case EXIT9OK3NOK2::

           EXIT:
              0
           STDOUT:
              fromH
              OK
              OK
              OK
           STDERR:
              NOK
              NOK

        """

        slst = []
        setUpperTreeSearchPath(os.path.abspath(os.path.dirname(__file__)),'epyunit',slst)
        
        epyu = findRelPathInSearchPath('bin/epyunit',slst,matchidx=0)
        scri = findRelPathInSearchPath('epyunit/myscript.sh',slst,matchidx=0)

        _call  = epyu
#        _call += " --rdbg=127.0.0.1:5678 "
        _call += " --rdbg "
#        _call += " --pass "
#        _call += " --passall "
#        _call += " --exitign=True "
        _call += " -- "
        _call += scri
        _call += " EXIT9OK3NOK2 "

        syskargs = {}
        
        #
        # make a simple system call, the actual unittest is processed within the subprocess 
        #
        sx = epyunit.SystemCalls.SystemCalls(**syskargs)

        callkargs = {}
        ret = sx.callit(_call,**callkargs)

        assert ret ==  [1, ['fromH', 'OK', 'OK', 'OK'], ['NOK', 'NOK']]
        pass
Exemplo n.º 12
0
    def testCase002(self):
        #for now windows only
        if platform.system() != 'Windows':
            unittest.SkipTest("Requires Windows - skipped!")
            return True
        if not os.path.exists('\\\\localhost\\C$'):
            unittest.SkipTest("Requires share for this test - skipped!")
            return True

        _s = sys.path[:]

        _rtype = 'SHARE'
        _host = 'localhost'
        _share,sp = os.path.splitdrive(os.path.abspath(os.path.dirname(__file__))+os.path.normpath('/a/b///c/d/b/c///'))
        _share = 'C$'
        start = getAppPrefixLocalPath((_rtype, _host, _share,sp,))

        s = os.sep
        s4 = 4*s
        top = 'pyfilesysobjects'+s4
        _res = []
        ret = setUpperTreeSearchPath(start,top,_res,**{'reverse':True}) #@UnusedVariable

        forDebugOnly = sys.path #@UnusedVariable

        _rtype = 'SHARE'
        _host = 'localhost'
        _share = 'C$'
        sp = sp
        mystart = getAppPrefixLocalPath((_rtype, _host, _share,sp,))

        mystart  = getTopFromPathString(top,[mystart])
#        myplist = [escapeFilePath(mystart),]
        myplist = [mystart,]
        res = []
        for i in range(len(_res)):
            res.append(getPythonPathRel(_res[i],myplist))

        resx = [
            '.',
            'tests',
            'tests\\30_libs',
            'tests\\30_libs\\040_FileSysObjects',
            'tests\\30_libs\\040_FileSysObjects\\070_setUpperTreeSearchPath',
            'tests\\30_libs\\040_FileSysObjects\\070_setUpperTreeSearchPath\\800_ieee1003',
            'tests\\30_libs\\040_FileSysObjects\\070_setUpperTreeSearchPath\\800_ieee1003\\Case030',
            'tests\\30_libs\\040_FileSysObjects\\070_setUpperTreeSearchPath\\800_ieee1003\\Case030\\a',
            'tests\\30_libs\\040_FileSysObjects\\070_setUpperTreeSearchPath\\800_ieee1003\\Case030\\a\\b',
            'tests\\30_libs\\040_FileSysObjects\\070_setUpperTreeSearchPath\\800_ieee1003\\Case030\\a\\b\\c',
            'tests\\30_libs\\040_FileSysObjects\\070_setUpperTreeSearchPath\\800_ieee1003\\Case030\\a\\b\\c\\d',
            'tests\\30_libs\\040_FileSysObjects\\070_setUpperTreeSearchPath\\800_ieee1003\\Case030\\a\\b\\c\\d\\b',
            'tests\\30_libs\\040_FileSysObjects\\070_setUpperTreeSearchPath\\800_ieee1003\\Case030\\a\\b\\c\\d\\b\\c'
        ]
        resx = map(os.path.normpath,resx)

        [ sys.path.pop() for x in range(len(sys.path)) ] #@UnusedVariable
        sys.path.extend(_s)

        assert resx == res
        pass
Exemplo n.º 13
0
    def testCase000(self):
        _s = sys.path[:]
        start = os.path.abspath(os.path.dirname(__file__))+os.path.normpath('/a/b/c')
        top = os.path.abspath(os.path.dirname(__file__))
        _res = []
        ret = setUpperTreeSearchPath(start,top,_res) #@UnusedVariable

        myplist = [getTopFromPathString('tests',[os.path.dirname(__file__)+os.sep+start])]
        res = []
        for i in range(len(_res)):
            _p = getPythonPathRel(_res[i],myplist)
            if _p:
                res.append(_p) 
        resx = [
            '30_libs/040_FileSysObjects/070_setUpperTreeSearchPath/800_ieee1003/Case020/a/b/c', 
            '30_libs/040_FileSysObjects/070_setUpperTreeSearchPath/800_ieee1003/Case020/a/b', 
            '30_libs/040_FileSysObjects/070_setUpperTreeSearchPath/800_ieee1003/Case020/a',
            '30_libs/040_FileSysObjects/070_setUpperTreeSearchPath/800_ieee1003/Case020',
        ]        
        resx = map(os.path.normpath,resx)

        res = map(unescapeFilePath, res)
        resx = map(unescapeFilePath, resx)

        [ sys.path.pop() for x in range(len(sys.path)) ] #@UnusedVariable
        sys.path.extend(_s)
        
        assert resx == res
        pass
Exemplo n.º 14
0
    def testCase012(self):

        if platform.system() != 'Windows':
            unittest.SkipTest("Requires Windows - skipped!")
            return True
       
        _s = sys.path[:]

        _share,start = os.path.splitdrive(os.path.abspath(os.path.dirname(__file__))+os.path.normpath('/a/b/c'))
        _share,top = os.path.splitdrive(os.path.abspath(os.path.dirname(__file__))+os.path.normpath('/a'))
        top = 'file://'+top
        _res = []
        ret = setUpperTreeSearchPath(start,top,_res,**{'ias':True}) #@UnusedVariable
        
        forDebugOnly = sys.path #@UnusedVariable
        
        myplist = [getTopFromPathString('tests',[start])]
        res = []
        for i in range(len(_res)):
            res.append(getPythonPathRel(_res[i],myplist)) 

        resx = [
            '30_libs/040_FileSysObjects/070_setUpperTreeSearchPath/800_ieee1003/Case020/a/b/c', 
            '30_libs/040_FileSysObjects/070_setUpperTreeSearchPath/800_ieee1003/Case020/a/b', 
            '30_libs/040_FileSysObjects/070_setUpperTreeSearchPath/800_ieee1003/Case020/a'
        ]
        resx = map(os.path.normpath,resx)

        [ sys.path.pop() for x in range(len(sys.path)) ] #@UnusedVariable
        sys.path.extend(_s)
        

        assert resx == res
        pass
Exemplo n.º 15
0
    def testCase002(self):
        _s = sys.path[:]
        start = os.path.dirname(__file__)+os.sep+'a/tests/a/b/tests/c/d/tests/b/c'
        start = os.path.abspath(start)
        
        top = 'tests'
        _res = []
        ret = setUpperTreeSearchPath(start,top,_res,**{'matchlvl':2,'relonly':True,'ias':True}) #@UnusedVariable
        
        forDebugOnly = sys.path #@UnusedVariable
        
        resx = [
            'c/d/tests/b/c', 
            'c/d/tests/b', 
            'c/d/tests', 
            'c/d', 
            'c'
        ]
        resx = map(os.path.normpath,resx)

        [ sys.path.pop() for x in range(len(sys.path)) ] #@UnusedVariable
        sys.path.extend(_s)
                
        assert resx == _res
        pass
Exemplo n.º 16
0
    def testCase000(self):
        _s = sys.path[:]

        A = os.path.normpath('a/A.txt')         #@UnusedVariable
        B = os.path.normpath('a/b/B.txt')       #@UnusedVariable
        C = os.path.normpath('a/b/c/C.txt')     #@UnusedVariable
        D = os.path.normpath('a/b/c/d/D.txt')   #@UnusedVariable

        start = os.path.abspath(os.path.dirname(__file__))
        top = start
        res = []
        ret = setUpperTreeSearchPath(start,top,res) #@UnusedVariable
        
        dx = "file://"+os.path.abspath(os.path.dirname(__file__)+os.sep+D)
        addPathToSearchPath(dx, res)

        res = map(os.path.abspath,res)
        res = map(os.path.normpath,res)
        
        resx = [
            os.path.dirname(__file__)+os.sep+D,
            os.path.abspath(os.path.dirname(__file__)),
        ]
        resx = map(os.path.abspath,resx)
        resx = map(os.path.normpath,resx)

        [ sys.path.pop() for x in range(len(sys.path)) ] #@UnusedVariable
        sys.path.extend(_s)

        res = map(unescapeFilePath, res)
        resx = map(unescapeFilePath, resx)
        
        self.assertEqual(resx, res)

        pass
Exemplo n.º 17
0
    def testCase003(self):
        _s = sys.path[:]
        start = os.path.dirname(__file__)+os.sep+'a/tests/a/b/tests/c/d/tests/b/c'
        start = os.path.abspath(start)

        top = 'tests'
        _res = []
        ret = setUpperTreeSearchPath(start,top,_res,**{'matchlvlupward':3,'relonly':True,'ias':True}) #@UnusedVariable
        
        forDebugOnly = sys.path #@UnusedVariable
        
        resx = [
            '30_libs/040_FileSysObjects/070_setUpperTreeSearchPath/240_relonly/Case030/a/tests/a/b/tests/c/d/tests/b/c', 
            '30_libs/040_FileSysObjects/070_setUpperTreeSearchPath/240_relonly/Case030/a/tests/a/b/tests/c/d/tests/b', 
            '30_libs/040_FileSysObjects/070_setUpperTreeSearchPath/240_relonly/Case030/a/tests/a/b/tests/c/d/tests', 
            '30_libs/040_FileSysObjects/070_setUpperTreeSearchPath/240_relonly/Case030/a/tests/a/b/tests/c/d', 
            '30_libs/040_FileSysObjects/070_setUpperTreeSearchPath/240_relonly/Case030/a/tests/a/b/tests/c', 
            '30_libs/040_FileSysObjects/070_setUpperTreeSearchPath/240_relonly/Case030/a/tests/a/b/tests', 
            '30_libs/040_FileSysObjects/070_setUpperTreeSearchPath/240_relonly/Case030/a/tests/a/b', 
            '30_libs/040_FileSysObjects/070_setUpperTreeSearchPath/240_relonly/Case030/a/tests/a', 
            '30_libs/040_FileSysObjects/070_setUpperTreeSearchPath/240_relonly/Case030/a/tests', 
            '30_libs/040_FileSysObjects/070_setUpperTreeSearchPath/240_relonly/Case030/a', 
            '30_libs/040_FileSysObjects/070_setUpperTreeSearchPath/240_relonly/Case030', 
            '30_libs/040_FileSysObjects/070_setUpperTreeSearchPath/240_relonly', 
            '30_libs/040_FileSysObjects/070_setUpperTreeSearchPath', 
            '30_libs/040_FileSysObjects', 
            '30_libs'
        ]
        resx = map(os.path.normpath,resx)
        
        [ sys.path.pop() for x in range(len(sys.path)) ] #@UnusedVariable
        sys.path.extend(_s)
                
        assert resx == _res
        pass
Exemplo n.º 18
0
    def testCase002(self):
        _s = sys.path[:]
        A = os.path.normpath('a/A.txt')         #@UnusedVariable
        B = os.path.normpath('a/b/B.txt')       #@UnusedVariable
        C = os.path.normpath('a/b/c/C.txt')     #@UnusedVariable
        D = os.path.normpath('a/b/c/d/D.txt')   #@UnusedVariable

        start = 'file://'+os.path.normpath(os.path.abspath(os.path.dirname(__file__)+os.sep+D))
        top = 'file://'+os.path.normpath('a/b')
        _res = []
        ret = setUpperTreeSearchPath(start,top,_res) #@UnusedVariable

        mypos = os.path.abspath(os.path.normpath(os.path.dirname(__file__)+"/../../"))   
        res = []
        for i in range(len(_res)):
            pr = getPythonPathRel(_res[i],[mypos])
            if pr:
                res.append(pr)
        resx =  ['110_uri\\Case030\\a\\b\\c\\d', '110_uri\\Case030\\a\\b\\c', '110_uri\\Case030\\a\\b']
        res = map(normpathX, res)
        resx = map(normpathX, resx)

        [ sys.path.pop() for x in range(len(sys.path)) ] #@UnusedVariable
        sys.path.extend(_s)
        
        assert resx == res
        pass
Exemplo n.º 19
0
    def testCase000(self):
        """Check defaults.
        """
        _s = sys.path[:]

        start = os.path.abspath(os.path.dirname(__file__))
        top = 'tests'
        _res = []
        ret = setUpperTreeSearchPath(start,top,_res) #@UnusedVariable
        
        mypos = os.path.abspath(os.path.normpath(os.path.dirname(__file__)+"/../../"))   
        res = []
        for i in range(len(_res)):
            pr = getPythonPathRel(_res[i],[mypos])
            if pr:
                res.append(pr)
        resx = [
            '100_general/Case020', '100_general', '.'
        ]        
        resx = map(os.path.normpath, resx)

        [ sys.path.pop() for x in range(len(sys.path)) ] #@UnusedVariable
        sys.path.extend(_s)
        

        assert resx == res
        pass
Exemplo n.º 20
0
    def testCase002(self):
        _s = sys.path[:]

        A = os.path.normpath('a/A.txt')         #@UnusedVariable
        B = os.path.normpath('a/b/B.txt')       #@UnusedVariable
        C = os.path.normpath('a/b/c/C.txt')     #@UnusedVariable
        D = os.path.normpath('a/b/c/d/D.txt')   #@UnusedVariable

        top = os.path.abspath(os.path.dirname(__file__))
        start = top+os.sep+C

        res = []
        ret = setUpperTreeSearchPath(start,top,res) #@UnusedVariable
        
        resx = [
            os.path.dirname(top+os.sep+C),
            top,
        ]
        resx.insert(1,os.path.dirname(resx[0][:-1]))
        resx.insert(2,os.path.dirname(resx[1][:-1]))

        [ sys.path.pop() for x in range(len(sys.path)) ] #@UnusedVariable
        sys.path.extend(_s)
        

        assert resx == res
        pass
Exemplo n.º 21
0
    def testCase000(self):
        _s = sys.path[:]
        #FIXME: Check and fix start = 'file://'+os.path.abspath(os.path.dirname(__file__))
        start = 'file://'+os.path.abspath(os.path.dirname(__file__))
        top = 'tests'
        _res = []
        ret = setUpperTreeSearchPath(start,top,_res) #@UnusedVariable
        
        forDebugOnly = sys.path #@UnusedVariable
        
        mypos = os.path.abspath(os.path.normpath(os.path.dirname(__file__)+"/../../"))   
        res = []
        for i in range(len(_res)):
            pr = getPythonPathRel(_res[i],[mypos])
            if pr:
                res.append(pr)
        resx = [
            '110_uri/Case020', 
            '110_uri', 
            '.'
        ]                
#        resx = map(os.path.normpath,resx)
        resx = map(filesysobjects.FileSysObjects.normpathX,resx)
        
        [ sys.path.pop() for x in range(len(sys.path)) ] #@UnusedVariable
        sys.path.extend(_s)

        self.assertEqual(resx ,res)
        pass
Exemplo n.º 22
0
    def testCase000(self):
        """Check defaults.
        """
        _s = sys.path[:]

        start = os.path.abspath(os.path.dirname(__file__)+os.sep+'a'+os.sep+'b'+os.sep+'c'+os.sep+'d'+os.sep+'b'+os.sep+'c'+os.sep)
        top = 'tests'
        _res = []
        ret = setUpperTreeSearchPath(start,top,_res) #@UnusedVariable
        
        mypos = os.path.abspath(os.path.normpath(os.path.dirname(__file__)+"/../"))   
        res = []
        for i in range(len(_res)):
            pr = getPythonPathRel(_res[i],[mypos])
            if pr:
                res.append(pr)
        resx =  ['Case030\\a\\b\\c\\d\\b\\c', 'Case030\\a\\b\\c\\d\\b', 'Case030\\a\\b\\c\\d', 'Case030\\a\\b\\c', 'Case030\\a\\b', 'Case030\\a', 'Case030', '.']
        res = map(normpathX, res)
        resx = map(normpathX, resx)

        [ sys.path.pop() for x in range(len(sys.path)) ] #@UnusedVariable
        sys.path.extend(_s)

        assert resx == res
        pass
Exemplo n.º 23
0
    def testCase000(self):
        """Check defaults.
        """
        _s = sys.path[:]

        start = os.path.dirname(__file__)+os.sep+'a'+os.sep+'b'+os.sep+'c'+os.sep+'d'+os.sep+'b'+os.sep+'c'+os.sep
        start = os.path.abspath(start)
        top = 'tests'
        _res = []
        ret = setUpperTreeSearchPath(start,top,_res,**{'reverse':True}) #@UnusedVariable
        
        mypos = os.path.abspath(os.path.normpath(os.path.dirname(__file__)+"/../../"))   
        res = []
        for i in range(len(_res)):
            pr = getPythonPathRel(_res[i],[mypos])
            if pr:
                res.append(pr)
        resx = [
            '.', 
            '300_reverse', 
            '300_reverse/Case030', 
            '300_reverse/Case030/a', 
            '300_reverse/Case030/a/b', 
            '300_reverse/Case030/a/b/c', 
            '300_reverse/Case030/a/b/c/d', 
            '300_reverse/Case030/a/b/c/d/b', 
            '300_reverse/Case030/a/b/c/d/b/c'
        ]
        resx = map(os.path.normpath,resx)

        [ sys.path.pop() for x in range(len(sys.path)) ] #@UnusedVariable
        sys.path.extend(_s)

        assert resx == res
        pass
Exemplo n.º 24
0
    def testCase000(self):
        _s = sys.path[:]

        A = os.path.normpath('a/A.txt')         #@UnusedVariable
        B = os.path.normpath('a/b/B.txt')       #@UnusedVariable
        C = os.path.normpath('a/b/c/C.txt')     #@UnusedVariable
        D = os.path.normpath('a/b/c/d/D.txt')   #@UnusedVariable

        start = os.path.abspath(os.path.dirname(__file__))
        top = start
        res = []
        ret = setUpperTreeSearchPath(start,top,res) #@UnusedVariable
        res.append(os.path.dirname(os.path.dirname(__file__)+os.sep+D))
        res.append(os.path.dirname(os.path.dirname(__file__)+os.sep+A))
        
        addPathToSearchPath(os.path.dirname(os.path.dirname(__file__)+os.sep+C), res,**{'pos':1})
        
        resx = [
            os.path.abspath(os.path.dirname(__file__)),
            os.path.dirname(os.path.dirname(__file__)+os.sep+C),
            os.path.dirname(os.path.dirname(__file__)+os.sep+D),
            os.path.dirname(os.path.dirname(__file__)+os.sep+A),
        ]

        [ sys.path.pop() for x in range(len(sys.path)) ] #@UnusedVariable
        sys.path.extend(_s)
        
        res = map(unescapeFilePath, res)
        resx = map(unescapeFilePath, resx)

        assert resx == res
        pass
Exemplo n.º 25
0
    def testCase000(self):

        slst = []
        setUpperTreeSearchPath(os.path.abspath(os.path.dirname(__file__)),'epyunit',slst)
        myscript = findRelPathInSearchPath('epyunit/myscript.sh',slst,matchidx=0)

        sx = epyunit.SystemCalls.SystemCalls()

#         _env = os.environ.copy()
#         _env['PATH'] = os.pathsep.join(sys.path)
          
        ret = sx.callit(myscript+" PRIO")

        assert ret[0] == 0
        assert ret[1] == ["fromC", 'arbitrary output', 'arbitrary signalling OK string', 'arbitrary output']
        assert ret[2] == ['arbitrary signalling ERROR string']
        pass
Exemplo n.º 26
0
    def testCase000(self):

        slst = []
        setUpperTreeSearchPath(os.path.abspath(os.path.dirname(__file__)),'epyunit',slst)
        myscript = call_scripy

        sx = epyunit.SystemCalls.SystemCalls()

#         _env = os.environ.copy()
#         _env['PATH'] = os.pathsep.join(sys.path)
          
        ret = sx.callit(myscript+" EXIT7")

        assert ret[0] == 7
        assert ret[1] == ["fromF", 'arbitrary output', 'arbitrary signalling NOK string', 'arbitrary output']
        assert ret[2] == []
        pass
Exemplo n.º 27
0
    def testCase000(self):

        slst = []
        setUpperTreeSearchPath(os.path.abspath(os.path.dirname(__file__)),'epyunit',slst)
        myscript = call_scripy

        sx = epyunit.SystemCalls.SystemCalls()

#         _env = os.environ.copy()
#         _env['PATH'] = os.pathsep.join(sys.path)
          
        ret = sx.callit(myscript+" DEFAULT")

        assert ret[0] == 123
        assert ret[1] == ['arbitrary output']
        assert ret[2] == []
        pass
Exemplo n.º 28
0
    def testCase000(self):

        slst = []
        setUpperTreeSearchPath(os.path.abspath(os.path.dirname(__file__)),'epyunit',slst)
        myscript = call_scripy

        sx = epyunit.SystemCalls.SystemCalls()

#         _env = os.environ.copy()
#         _env['PATH'] = os.pathsep.join(sys.path)
          
        ret = sx.callit(myscript+" EXIT8")

        assert ret[0] == 8
        assert ret[1] == ["fromG", 'arbitrary output', 'arbitrary signalling NOK string', 'arbitrary output']
        assert ret[2] == ['arbitrary err output', 'arbitrary err signalling NOK string', 'arbitrary err output']
        pass
Exemplo n.º 29
0
    def testCase000(self):

        slst = []
        setUpperTreeSearchPath(os.path.abspath(os.path.dirname(__file__)),'epyunit',slst)
        myscript = findRelPathInSearchPath('epyunit/myscript.sh',slst,matchidx=0)

        sx = epyunit.SystemCalls.SystemCalls()

#         _env = os.environ.copy()
#         _env['PATH'] = os.pathsep.join(sys.path)
          
        ret = sx.callit(myscript+" EXIT9OK3NOK2")

        assert ret[0] == 9
        assert ret[1] == ['fromH', 'OK', 'OK', 'OK']
        assert ret[2] == ['NOK', 'NOK', ]
        pass
Exemplo n.º 30
0
    def testCase000(self):
        slst = []
        setUpperTreeSearchPath(os.path.abspath(os.path.dirname(__file__)),'epyunit',slst)

        epyu = findRelPathInSearchPath('bin/epyunit',slst,matchidx=0)
        scri = findRelPathInSearchPath('epyunit/myscript.sh',slst,matchidx=0)

        _call = epyu
        _call += " --priotype=False " + scri
        _call += " EXIT9OK3NOK2 "

        syskargs = {}
        sx = epyunit.SystemCalls.SystemCalls(**syskargs)

        callkargs = {}
        ret = sx.callit(_call,**callkargs)

        assert ret == [1, ['fromH', 'OK', 'OK', 'OK'], ['NOK', 'NOK']]
        pass
Exemplo n.º 31
0
    def testCase000(self):
        slst = []
        setUpperTreeSearchPath(os.path.abspath(os.path.dirname(__file__)),
                               'epyunit', slst)

        epyu = findRelPathInSearchPath('bin/epyunit', slst, matchidx=0)
        scri = findRelPathInSearchPath('epyunit/myscript.sh', slst, matchidx=0)

        _call = epyu
        _call += " --priotype=False " + scri
        _call += " EXIT9OK3NOK2 "

        syskargs = {}
        sx = epyunit.SystemCalls.SystemCalls(**syskargs)

        callkargs = {}
        ret = sx.callit(_call, **callkargs)

        assert ret == [1, ['fromH', 'OK', 'OK', 'OK'], ['NOK', 'NOK']]
        pass
Exemplo n.º 32
0
    def testCase000(self):

        slst = []
        setUpperTreeSearchPath(os.path.abspath(os.path.dirname(__file__)),'epyunit',slst)
        
        epyu = findRelPathInSearchPath('bin/epyunit',slst,matchidx=0)
        scri = findRelPathInSearchPath('epyunit/myscript.sh',slst,matchidx=0)

        _call = epyu
        _call += " " + scri
        _call += " OK "

        syskargs = {}
        sx = epyunit.SystemCalls.SystemCalls(**syskargs)

        callkargs = {}
        ret = sx.callit(_call,**callkargs)

        assert ret == [0, ['fromA', 'arbitrary output', 'arbitrary signalling OK string', 'arbitrary output' ], [],]
        pass
Exemplo n.º 33
0
    def __init__(self,*args,**kargs):
        """Initialize common refence and data"""
        
        super(CallUnits,self).__init__(*args,**kargs)
        
        _s = sys.path[:]

        import testdata
          
        s = os.sep
        
        # start of upward search - file is converted into it's containing directory node
        any_sub_path = os.path.normpath('examples/a/b0/c/a/b0/c/F')
        spath  = testdata.mypath
        spath += s+ any_sub_path

        # check environment
        assert os.path.exists(spath)
                
        # store new search list, here without required sys.path
        self._plist = []


        # 0. build a search path list - if not yet available
        #    adds each directory from spath to its matching 
        #    subnode  "a/b"
        #
        setUpperTreeSearchPath(spath,os.path.normpath(r'a/b0'), self._plist)
        self._plist_ref = [ # expected plist
            os.path.normpath(testdata.mypath+'/examples/a/b0/c/a/b0/c'),
            os.path.normpath(testdata.mypath+'/examples/a/b0/c/a/b0'),
            os.path.normpath(testdata.mypath+'/examples/a/b0/c/a'),
            os.path.normpath(testdata.mypath+'/examples/a/b0/c'),
            os.path.normpath(testdata.mypath+'/examples/a/b0'),
        ]
        assert self._plist_ref == self._plist 
Exemplo n.º 34
0
    def testCase010(self):

        #for now windows only
        #for now windows only
        if platform.system() != 'Windows':
            unittest.SkipTest("Requires Windows - skipped!")
            return True
        
        _s = sys.path[:]

        start0 = os.path.abspath(os.path.dirname(__file__)+os.sep+os.path.normpath('/a/b/c'))
        start1 = os.sep + start0
    
        # normalize
        _start_elems = splitAppPrefix(start0,**{'ias':True})
        start= getAppPrefixLocalPath(_start_elems)

        assert start0 == start

        top = 'file://'+os.path.splitdrive(os.path.abspath(os.path.dirname(__file__)))[1]

        _res = []
        ret = setUpperTreeSearchPath(start,top,_res,**{'ias':True}) #@UnusedVariable
        
        forDebugOnly = sys.path #@UnusedVariable
        
        myplist = [getTopFromPathString('tests',[start])]
        res = []
        for i in range(len(_res)):
            res.append(getPythonPathRel(_res[i],myplist)) 

        resx = [
            '30_libs/040_FileSysObjects/070_setUpperTreeSearchPath/800_ieee1003/Case020/a/b/c', 
            '30_libs/040_FileSysObjects/070_setUpperTreeSearchPath/800_ieee1003/Case020/a/b', 
            '30_libs/040_FileSysObjects/070_setUpperTreeSearchPath/800_ieee1003/Case020/a',
            '30_libs/040_FileSysObjects/070_setUpperTreeSearchPath/800_ieee1003/Case020',
        ]
        resx = map(os.path.normpath,resx)

        [ sys.path.pop() for x in range(len(sys.path)) ] #@UnusedVariable
        sys.path.extend(_s)
        
        assert resx == res
        pass
Exemplo n.º 35
0
 def testCase001(self):
     _s = sys.path[:]
     start = 'file://'+os.path.abspath(os.path.dirname(__file__))
     top = 'tests'
     _res = []
     ret = setUpperTreeSearchPath(start,top,_res,**{'reverse':True}) #@UnusedVariable
     
     mypos = os.path.abspath(os.path.normpath(os.path.dirname(__file__)+"/../../"))   
     res = []
     for i in range(len(_res)):
         pr = getPythonPathRel(_res[i],[mypos])
         if pr:
             res.append(pr)
     resx = ['.', '110_uri', '110_uri\\Case020']
     resx = map(filesysobjects.FileSysObjects.normpathX,resx)
     
     [ sys.path.pop() for x in range(len(sys.path)) ] #@UnusedVariable
     sys.path.extend(_s)
     
     assert resx == res
     pass
Exemplo n.º 36
0
    def testCase002(self):

        _s = sys.path[:]
        
        start0 = os.path.abspath(os.path.dirname(__file__)+os.sep+os.path.normpath('/a/b/c'))
        d,p = os.path.splitdrive(start0)
        start1 = os.sep + p
    
        # normalize
        _start_elems = splitAppPrefix(start0,**{'ias':True})
        start= getAppPrefixLocalPath(_start_elems)

        assert start0 == start
        
        top = 'tests/'
        _res = []
        ret = setUpperTreeSearchPath(start,top,_res,**{'ias':True}) #@UnusedVariable

        myplist = [getTopFromPathString('tests',[start])]
        res = []
        for i in range(len(_res)):
            res.append(getPythonPathRel(_res[i],myplist)) 
        resx = [
            '30_libs/040_FileSysObjects/070_setUpperTreeSearchPath/800_ieee1003/Case020/a/b/c', 
            '30_libs/040_FileSysObjects/070_setUpperTreeSearchPath/800_ieee1003/Case020/a/b', 
            '30_libs/040_FileSysObjects/070_setUpperTreeSearchPath/800_ieee1003/Case020/a',
            '30_libs/040_FileSysObjects/070_setUpperTreeSearchPath/800_ieee1003/Case020',
            '30_libs/040_FileSysObjects/070_setUpperTreeSearchPath/800_ieee1003',
            '30_libs/040_FileSysObjects/070_setUpperTreeSearchPath',
            '30_libs/040_FileSysObjects',
            '30_libs',
            '.',
        ]        
        resx = map(os.path.normpath,resx)

        [ sys.path.pop() for x in range(len(sys.path)) ] #@UnusedVariable
        sys.path.extend(_s)
        
        assert resx == res
        pass
Exemplo n.º 37
0
    def testCase001(self):
        """Check error condition.
        """
        _s = sys.path[:]
        A = os.path.normpath('a/A.txt')        #@UnusedVariable
        B = os.path.normpath('a/b/B.txt')      #@UnusedVariable
        C = os.path.normpath('a/b/c/C.txt')    #@UnusedVariable
        D = os.path.normpath('a/b/c/d/D.txt')  #@UnusedVariable

        start = ''
        top = None
        res = []
        try:
            ret = setUpperTreeSearchPath(start,top,res) #@UnusedVariable
        except FileSysObjectsException:
            pass
        else:
            raise
        pass

        [ sys.path.pop() for x in range(len(sys.path)) ] #@UnusedVariable
        sys.path.extend(_s)
Exemplo n.º 38
0
__version__ = '0.0.1'
__uuid__ = '9de52399-7752-4633-9fdc-66c87a9200b8'

__docformat__ = "restructuredtext en"

import unittest
import os, sys

from filesysobjects.FileSysObjects import setUpperTreeSearchPath, findRelPathInSearchPath
import epyunit.SystemCalls

#
#######################
#
slst = []
setUpperTreeSearchPath(os.path.abspath(os.path.dirname(__file__)), 'epyunit',
                       slst)

epyu = findRelPathInSearchPath('bin/epyunit', slst, matchidx=0)
scri = findRelPathInSearchPath('epyunit/myscript.sh', slst, matchidx=0)


class CallUnits(unittest.TestCase):
    def testCase010(self):
        _call = epyu + " --priotype=False "
        #_call += " --rdbg -- "
        _call += " -- "
        _call += scri + " OK "

        syskargs = {}
        sx = epyunit.SystemCalls.SystemCalls(**syskargs)