コード例 #1
0
 def test_invalidSiteDir(self):
     """
     Test that invalid entries in syspath doesn't cause addsitedir to raise
     an error.
     """
     dir1, dir2 = self.makeSomeDirs()
     syspath = [17]
     addsitedir(dir1, syspath)
     del syspath[0]
     self.assertEqual(syspath, [os.path.abspath(x) for x in (dir1, dir2)])
コード例 #2
0
ファイル: test_xsite.py プロジェクト: rcarmo/divmod.org
 def test_invalidSiteDir(self):
     """
     Test that invalid entries in syspath doesn't cause addsitedir to raise
     an error.
     """
     dir1, dir2 = self.makeSomeDirs()
     syspath = [17]
     addsitedir(dir1, syspath)
     del syspath[0]
     self.assertEqual(syspath, [os.path.abspath(x) for x in (dir1, dir2)])
コード例 #3
0
ファイル: test_xsite.py プロジェクト: rcarmo/divmod.org
 def test_extraPthBits(self):
     """
     Test that comments are ignored and import statements are honored in pth
     files.
     """
     dir1 = self.mktemp()
     os.makedirs(dir1)
     dir2 = os.path.join(dir1, "subdir")
     os.makedirs(dir2)
     pthfile = file(os.path.join(os.path.abspath(dir1), "test.pth"), 'w')
     pthfile.write("import sys\n#a comment\nsubdir\n")
     pthfile.close()
     syspath = []
     addsitedir(dir1, syspath)
     self.assertEqual(syspath, [os.path.abspath(x) for x in (dir1, dir2)])
コード例 #4
0
ファイル: test_xsite.py プロジェクト: rcarmo/divmod.org
 def test_addSiteDir(self):
     """
     Test that addSiteDir reads .pth files and adds them to the path passed
     to it.
     """
     dir1, dir2 = self.makeSomeDirs()
     syspath = []
     addsitedir(dir1, syspath)
     self.assertEqual(syspath, [os.path.abspath(x) for x in (dir1, dir2)])
     dir3 = self.mktemp()
     os.makedirs(dir3)
     syspath = [dir3]
     addsitedir(dir1, syspath)
     self.assertEqual(syspath, [dir3] + [os.path.abspath(x)
                                         for x in (dir1, dir2)])
コード例 #5
0
 def test_extraPthBits(self):
     """
     Test that comments are ignored and import statements are honored in pth
     files.
     """
     dir1 = self.mktemp()
     os.makedirs(dir1)
     dir2 = os.path.join(dir1, "subdir")
     os.makedirs(dir2)
     pthfile = file(os.path.join(os.path.abspath(dir1), "test.pth"), 'w')
     pthfile.write("import sys\n#a comment\nsubdir\n")
     pthfile.close()
     syspath = []
     addsitedir(dir1, syspath)
     self.assertEqual(syspath, [os.path.abspath(x) for x in (dir1, dir2)])
コード例 #6
0
 def test_addSiteDir(self):
     """
     Test that addSiteDir reads .pth files and adds them to the path passed
     to it.
     """
     dir1, dir2 = self.makeSomeDirs()
     syspath = []
     addsitedir(dir1, syspath)
     self.assertEqual(syspath, [os.path.abspath(x) for x in (dir1, dir2)])
     dir3 = self.mktemp()
     os.makedirs(dir3)
     syspath = [dir3]
     addsitedir(dir1, syspath)
     self.assertEqual(syspath,
                      [dir3] + [os.path.abspath(x) for x in (dir1, dir2)])
コード例 #7
0
def addSiteDir(fsPath, syspath):
    """
    Add C{fsPath} to C{syspath} and remove all preceding entries, if it's not
    already present.
    """
    if fsPath not in syspath:
        chop = len(syspath)
        xsite.addsitedir(fsPath, syspath)
        # Put everything at the beginning of the path (overriding the site
        # installation directory), since Python likes to put it at the end.
        spc = syspath[chop:]
        del syspath[chop:]
        syspath[0:0] = spc
    elif 0:  # We SHOULD emit a warning here, but all kinds
        # of tests set PYTHONPATH invalidly and cause
        # havoc.
        warn("Duplicate path entry %r" % (fsPath, ), UserWarning)
コード例 #8
0
ファイル: branchmgr.py プロジェクト: rcarmo/divmod.org
def addSiteDir(fsPath, syspath):
    """
    Add C{fsPath} to C{syspath} and remove all preceding entries, if it's not
    already present.
    """
    if fsPath not in syspath:
        chop = len(syspath)
        xsite.addsitedir(fsPath, syspath)
        # Put everything at the beginning of the path (overriding the site
        # installation directory), since Python likes to put it at the end.
        spc = syspath[chop:]
        del syspath[chop:]
        syspath[0:0] = spc
    elif 0:                     # We SHOULD emit a warning here, but all kinds
                                # of tests set PYTHONPATH invalidly and cause
                                # havoc.
        warn("Duplicate path entry %r" % (fsPath,),
             UserWarning )