Exemple #1
0
 def test_islink(self):
     self.assertIs(posixpath.islink(support.TESTFN + "1"), False)
     self.assertIs(posixpath.lexists(support.TESTFN + "2"), False)
     with open(support.TESTFN + "1", "wb") as f:
         f.write(b"foo")
     self.assertIs(posixpath.islink(support.TESTFN + "1"), False)
     if support.can_symlink():
         os.symlink(support.TESTFN + "1", support.TESTFN + "2")
         self.assertIs(posixpath.islink(support.TESTFN + "2"), True)
         os.remove(support.TESTFN + "1")
         self.assertIs(posixpath.islink(support.TESTFN + "2"), True)
         self.assertIs(posixpath.exists(support.TESTFN + "2"), False)
         self.assertIs(posixpath.lexists(support.TESTFN + "2"), True)
 def test_islink(self):
     self.assertIs(posixpath.islink(support.TESTFN + "1"), False)
     self.assertIs(posixpath.lexists(support.TESTFN + "2"), False)
     with open(support.TESTFN + "1", "wb") as f:
         f.write(b"foo")
     self.assertIs(posixpath.islink(support.TESTFN + "1"), False)
     if support.can_symlink():
         os.symlink(support.TESTFN + "1", support.TESTFN + "2")
         self.assertIs(posixpath.islink(support.TESTFN + "2"), True)
         os.remove(support.TESTFN + "1")
         self.assertIs(posixpath.islink(support.TESTFN + "2"), True)
         self.assertIs(posixpath.exists(support.TESTFN + "2"), False)
         self.assertIs(posixpath.lexists(support.TESTFN + "2"), True)
Exemple #3
0
    def test_islink(self):
        self.assertIs(posixpath.islink(test_support.TESTFN + "1"), False)
        f = open(test_support.TESTFN + "1", "wb")
        try:
            f.write("foo")
            f.close()
            self.assertIs(posixpath.islink(test_support.TESTFN + "1"), False)
            if hasattr(os, "symlink"):
                os.symlink(test_support.TESTFN + "1",
                           test_support.TESTFN + "2")
                self.assertIs(posixpath.islink(test_support.TESTFN + "2"),
                              True)
                os.remove(test_support.TESTFN + "1")
                self.assertIs(posixpath.islink(test_support.TESTFN + "2"),
                              True)
                self.assertIs(posixpath.exists(test_support.TESTFN + "2"),
                              False)
                self.assertIs(posixpath.lexists(test_support.TESTFN + "2"),
                              True)
        finally:
            if not f.close():
                f.close()
            try:
                os.remove(test_support.TESTFN + "1")
            except os.error:
                pass
            try:
                os.remove(test_support.TESTFN + "2")
            except os.error:
                pass

        self.assertRaises(TypeError, posixpath.islink)
Exemple #4
0
    def test_islink(self):
        self.assertIs(posixpath.islink(test_support.TESTFN + "1"), False)
        f = open(test_support.TESTFN + "1", "wb")
        try:
            f.write("foo")
            f.close()
            self.assertIs(posixpath.islink(test_support.TESTFN + "1"), False)
            if hasattr(os, "symlink"):
                os.symlink(test_support.TESTFN + "1", test_support.TESTFN + "2")
                self.assertIs(posixpath.islink(test_support.TESTFN + "2"), True)
                os.remove(test_support.TESTFN + "1")
                self.assertIs(posixpath.islink(test_support.TESTFN + "2"), True)
                self.assertIs(posixpath.exists(test_support.TESTFN + "2"), False)
                self.assertIs(posixpath.lexists(test_support.TESTFN + "2"), True)
        finally:
            if not f.close():
                f.close()
            try:
                os.remove(test_support.TESTFN + "1")
            except os.error:
                pass
            try:
                os.remove(test_support.TESTFN + "2")
            except os.error:
                pass

        self.assertRaises(TypeError, posixpath.islink)
 def test_islink(self):
     self.assertIs(posixpath.islink(support.TESTFN + "1"), False)
     self.assertIs(posixpath.lexists(support.TESTFN + "2"), False)
     f = open(support.TESTFN + "1", "wb")
     try:
         f.write(b"foo")
         f.close()
         self.assertIs(posixpath.islink(support.TESTFN + "1"), False)
         if support.can_symlink():
             os.symlink(support.TESTFN + "1", support.TESTFN + "2")
             self.assertIs(posixpath.islink(support.TESTFN + "2"), True)
             os.remove(support.TESTFN + "1")
             self.assertIs(posixpath.islink(support.TESTFN + "2"), True)
             self.assertIs(posixpath.exists(support.TESTFN + "2"), False)
             self.assertIs(posixpath.lexists(support.TESTFN + "2"), True)
     finally:
         if not f.close():
             f.close()
Exemple #6
0
 def test_islink(self):
     self.assertIs(posixpath.islink(support.TESTFN + "1"), False)
     self.assertIs(posixpath.lexists(support.TESTFN + "2"), False)
     f = open(support.TESTFN + "1", "wb")
     try:
         f.write(b"foo")
         f.close()
         self.assertIs(posixpath.islink(support.TESTFN + "1"), False)
         if support.can_symlink():
             os.symlink(support.TESTFN + "1", support.TESTFN + "2")
             self.assertIs(posixpath.islink(support.TESTFN + "2"), True)
             os.remove(support.TESTFN + "1")
             self.assertIs(posixpath.islink(support.TESTFN + "2"), True)
             self.assertIs(posixpath.exists(support.TESTFN + "2"), False)
             self.assertIs(posixpath.lexists(support.TESTFN + "2"), True)
     finally:
         if not f.close():
             f.close()
 def test_islink(self):
     self.assertIs(posixpath.islink(support.TESTFN + '1'), False)
     self.assertIs(posixpath.lexists(support.TESTFN + '2'), False)
     f = open(support.TESTFN + '1', 'wb')
     try:
         f.write(b'foo')
         f.close()
         self.assertIs(posixpath.islink(support.TESTFN + '1'), False)
         if support.can_symlink():
             os.symlink(support.TESTFN + '1', support.TESTFN + '2')
             self.assertIs(posixpath.islink(support.TESTFN + '2'), True)
             os.remove(support.TESTFN + '1')
             self.assertIs(posixpath.islink(support.TESTFN + '2'), True)
             self.assertIs(posixpath.exists(support.TESTFN + '2'), False)
             self.assertIs(posixpath.lexists(support.TESTFN + '2'), True)
     finally:
         if not f.close():
             f.close()
Exemple #8
0
    def test_islink(self):
        self.assertIs(posixpath.islink(os_helper.TESTFN + "1"), False)
        self.assertIs(posixpath.lexists(os_helper.TESTFN + "2"), False)

        with open(os_helper.TESTFN + "1", "wb") as f:
            f.write(b"foo")
        self.assertIs(posixpath.islink(os_helper.TESTFN + "1"), False)

        if os_helper.can_symlink():
            os.symlink(os_helper.TESTFN + "1", os_helper.TESTFN + "2")
            self.assertIs(posixpath.islink(os_helper.TESTFN + "2"), True)
            os.remove(os_helper.TESTFN + "1")
            self.assertIs(posixpath.islink(os_helper.TESTFN + "2"), True)
            self.assertIs(posixpath.exists(os_helper.TESTFN + "2"), False)
            self.assertIs(posixpath.lexists(os_helper.TESTFN + "2"), True)

        self.assertIs(posixpath.islink(os_helper.TESTFN + "\udfff"), False)
        self.assertIs(posixpath.islink(os.fsencode(os_helper.TESTFN) + b"\xff"), False)
        self.assertIs(posixpath.islink(os_helper.TESTFN + "\x00"), False)
        self.assertIs(posixpath.islink(os.fsencode(os_helper.TESTFN) + b"\x00"), False)
Exemple #9
0
 def test_islink(self):
     self.assertIs(posixpath.islink(support.TESTFN + "1"), False)
     self.assertIs(posixpath.lexists(support.TESTFN + "2"), False)
     f = open(support.TESTFN + "1", "wb")
     try:
         f.write(b"foo")
         f.close()
         self.assertIs(posixpath.islink(support.TESTFN + "1"), False)
     finally:
         if not f.close():
             f.close()
    def test_exists(self):
        self.assertIs(posixpath.exists(test_support.TESTFN), False)
        f = open(test_support.TESTFN, "wb")
        try:
            f.write("foo")
            f.close()
            self.assertIs(posixpath.exists(test_support.TESTFN), True)
            self.assertIs(posixpath.lexists(test_support.TESTFN), True)
        finally:
            if not f.close():
                f.close()

        self.assertRaises(TypeError, posixpath.exists)
Exemple #11
0
    def test_exists(self):
        self.assertIs(posixpath.exists(test_support.TESTFN), False)
        f = open(test_support.TESTFN, "wb")
        try:
            f.write("foo")
            f.close()
            self.assertIs(posixpath.exists(test_support.TESTFN), True)
            self.assertIs(posixpath.lexists(test_support.TESTFN), True)
        finally:
            if not f.close():
                f.close()

        self.assertRaises(TypeError, posixpath.exists)
Exemple #12
0
 def test_islink(self):
     self.assertIs(posixpath.islink(test_support.TESTFN + "1"), False)
     f = open(test_support.TESTFN + "1", "org.eclipse.wb")
     try:
         f.write("foo")
         f.close()
         self.assertIs(posixpath.islink(test_support.TESTFN + "1"), False)
         if hasattr(os, "symlink"):
             os.symlink(test_support.TESTFN + "1",
                        test_support.TESTFN + "2")
             self.assertIs(posixpath.islink(test_support.TESTFN + "2"),
                           True)
             os.remove(test_support.TESTFN + "1")
             self.assertIs(posixpath.islink(test_support.TESTFN + "2"),
                           True)
             self.assertIs(posixpath.exists(test_support.TESTFN + "2"),
                           False)
             self.assertIs(posixpath.lexists(test_support.TESTFN + "2"),
                           True)
     finally:
         if not f.close():
             f.close()
# IMPORT

from posixpath import dirname, lexists, realpath
from subprocess import Popen

from pywildmatch._lib import *
from pywildmatch.param import Param

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# GLOBAL

# PATH TO wildmatch.exe
# BUILT FROM libgit2, pywildmatch/test/extra/wildmatch_exe.c
DIR = dirname(dirname(realpath(__file__)))
EXE = '/'.join((DIR, 'extra', 'wildmatch.exe'))
assert lexists(EXE), '''
    EXPECTED THIS PATH FOR libgit2 WILDMATCH TEST: %s
''' % EXE

# GENERIC re.Match OBJECT
matchObj = sre_compile('').match('')

max_flag = 3

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# libgit2 WILDMATCH


def run(pattern, text, flag):
    cmd = [EXE, pattern, text, str(flag)]
    PIPE = -1
Exemple #14
0
 def update_event(self, inp=-1):
     self.set_output_val(0, posixpath.lexists(self.input(0)))