예제 #1
0
def test_chmod():
    # chmod tests:
    # BUG 828,830
    nt.mkdir('tmp2')
    nt.chmod('tmp2', 256)  # NOTE: change to flag when stat is implemented
    AssertError(OSError, lambda: nt.rmdir('tmp2'))
    nt.chmod('tmp2', 128)
    nt.rmdir('tmp2')
예제 #2
0
파일: nt_test.py 프로젝트: 89sos98/main
def test_chmod():
    # chmod tests:
    # BUG 828,830
    nt.mkdir('tmp2')
    nt.chmod('tmp2', 256) # NOTE: change to flag when stat is implemented
    AssertError(OSError, lambda:nt.rmdir('tmp2'))
    nt.chmod('tmp2', 128)
    nt.rmdir('tmp2')
예제 #3
0
def test_cp24692():
    import errno, nt, stat
    dir_name = "cp24692_testdir"
    try:
        nt.mkdir(dir_name)
        nt.chmod(dir_name, stat.S_IREAD)
        try:
            nt.rmdir(dir_name)
        except WindowsError, e:
            pass
        AreEqual(e.errno, errno.EACCES)
예제 #4
0
파일: regressions.py 프로젝트: 89sos98/main
def test_cp24692():
    import errno, nt, stat
    dir_name = "cp24692_testdir"
    try:
        nt.mkdir(dir_name)
        nt.chmod(dir_name, stat.S_IREAD)
        try:
            nt.rmdir(dir_name)
        except WindowsError, e:
            pass
        AreEqual(e.errno, errno.EACCES)
예제 #5
0
def test_overwrite_readonly():
    filename = "tmp.txt"
    f = file(filename, "w+")
    f.write("I am read-only")
    f.close()
    nt.chmod(filename, 256)
    try:
        try:
            f = file(filename, "w+")  # FAIL
        finally:
            nt.chmod(filename, 128)
            nt.unlink(filename)
    except IOError, e:
        pass
예제 #6
0
파일: test_file.py 프로젝트: mdavid/dlr
def test_overwrite_readonly():
    filename = "tmp.txt"
    f = file(filename, "w+")
    f.write("I am read-only")
    f.close()
    nt.chmod(filename, 256)
    try:
        try:
            f = file(filename, "w+") # FAIL
        finally:
            nt.chmod(filename, 128)
            nt.unlink(filename)
    except IOError, e:
        pass
예제 #7
0
def test_overwrite_readonly():
    filename = "tmp.txt"
    f = file(filename, "w+")
    f.write("I am read-only")
    f.close()
    nt.chmod(filename, 256)
    try:
        try:
            f = file(filename, "w+") # FAIL
        finally:
            nt.chmod(filename, 128)
            nt.unlink(filename)
    except IOError as e:
        pass
    else:
        AssertUnreachable() # should throw
예제 #8
0
파일: nt_test.py 프로젝트: slide/main
def test_access():
    f = file("new_file_name", "w")
    f.close()

    AreEqual(nt.access("new_file_name", nt.F_OK), True)
    AreEqual(nt.access("does_not_exist.py", nt.F_OK), False)

    nt.chmod("new_file_name", 0x100)  # S_IREAD
    AreEqual(nt.access("new_file_name", nt.W_OK), False)
    nt.chmod("new_file_name", 0x80)  # S_IWRITE

    nt.unlink("new_file_name")

    nt.mkdir("new_dir_name")
    AreEqual(nt.access("new_dir_name", nt.R_OK), True)
    nt.rmdir("new_dir_name")

    AssertError(TypeError, nt.access, None, 1)
예제 #9
0
파일: nt_test.py 프로젝트: 89sos98/main
def test_access():
    f = file('new_file_name', 'w')
    f.close()
    
    AreEqual(nt.access('new_file_name', nt.F_OK), True)
    AreEqual(nt.access('does_not_exist.py', nt.F_OK), False)

    nt.chmod('new_file_name', 0x100) # S_IREAD
    AreEqual(nt.access('new_file_name', nt.W_OK), False)
    nt.chmod('new_file_name', 0x80)  # S_IWRITE
        
    nt.unlink('new_file_name')
    
    nt.mkdir('new_dir_name')
    AreEqual(nt.access('new_dir_name', nt.R_OK), True)
    nt.rmdir('new_dir_name')
    
    AssertError(TypeError, nt.access, None, 1)
예제 #10
0
def test_access():
    f = file('new_file_name', 'w')
    f.close()
    
    AreEqual(nt.access('new_file_name', nt.F_OK), True)
    AreEqual(nt.access('does_not_exist.py', nt.F_OK), False)

    nt.chmod('new_file_name', 0x100) # S_IREAD
    AreEqual(nt.access('new_file_name', nt.W_OK), False)
    nt.chmod('new_file_name', 0x80)  # S_IWRITE
        
    nt.unlink('new_file_name')
    
    nt.mkdir('new_dir_name')
    AreEqual(nt.access('new_dir_name', nt.R_OK), True)
    nt.rmdir('new_dir_name')
    
    AssertError(TypeError, nt.access, None, 1)
예제 #11
0
    def test_access(self):
        open('new_file_name', 'w').close()

        self.assertEqual(nt.access('new_file_name', nt.F_OK), True)
        self.assertEqual(nt.access('new_file_name', nt.R_OK), True)
        self.assertEqual(nt.access('does_not_exist.py', nt.F_OK), False)
        self.assertEqual(nt.access('does_not_exist.py', nt.R_OK), False)

        nt.chmod('new_file_name', 0x100) # S_IREAD
        self.assertEqual(nt.access('new_file_name', nt.W_OK), False)
        nt.chmod('new_file_name', 0x80)  # S_IWRITE

        nt.unlink('new_file_name')

        nt.mkdir('new_dir_name')
        self.assertEqual(nt.access('new_dir_name', nt.R_OK), True)
        nt.rmdir('new_dir_name')

        self.assertRaises(TypeError, nt.access, None, 1)
예제 #12
0
    def test_remove_negative(self):
        import stat
        self.assertRaisesNumber(WindowsError, errno.ENOENT, lambda : nt.remove('some_file_that_does_not_exist'))
        try:
            open('some_test_file.txt', 'w').close()
            nt.chmod('some_test_file.txt', stat.S_IREAD)
            self.assertRaisesNumber(WindowsError, errno.EACCES, lambda : nt.remove('some_test_file.txt'))
            nt.chmod('some_test_file.txt', stat.S_IWRITE)

            with open('some_test_file.txt', 'w+'):
                self.assertRaisesNumber(WindowsError, errno.EACCES, lambda : nt.remove('some_test_file.txt'))
        finally:
            nt.chmod('some_test_file.txt', stat.S_IWRITE)
            nt.unlink('some_test_file.txt')
예제 #13
0
파일: nt_test.py 프로젝트: 89sos98/main
def test_remove_negative():
    import stat
    AssertErrorWithNumber(WindowsError, errno.ENOENT, lambda : nt.remove('some_file_that_does_not_exist'))
    try:
        file('some_test_file.txt', 'w').close()
        nt.chmod('some_test_file.txt', stat.S_IREAD)
        AssertErrorWithNumber(WindowsError, errno.EACCES, lambda : nt.remove('some_test_file.txt'))
        nt.chmod('some_test_file.txt', stat.S_IWRITE)
        
        f = file('some_test_file.txt', 'w+')
        AssertErrorWithNumber(WindowsError, errno.EACCES, lambda : nt.remove('some_test_file.txt'))
        f.close()
    finally:
        nt.chmod('some_test_file.txt', stat.S_IWRITE)
        nt.unlink('some_test_file.txt')
예제 #14
0
def test_remove_negative():
    import stat
    AssertErrorWithNumber(WindowsError, errno.ENOENT, lambda : nt.remove('some_file_that_does_not_exist'))
    try:
        file('some_test_file.txt', 'w').close()
        nt.chmod('some_test_file.txt', stat.S_IREAD)
        AssertErrorWithNumber(WindowsError, errno.EACCES, lambda : nt.remove('some_test_file.txt'))
        nt.chmod('some_test_file.txt', stat.S_IWRITE)
        
        f = file('some_test_file.txt', 'w+')
        AssertErrorWithNumber(WindowsError, errno.EACCES, lambda : nt.remove('some_test_file.txt'))
        f.close()
    finally:
        nt.chmod('some_test_file.txt', stat.S_IWRITE)
        nt.unlink('some_test_file.txt')
예제 #15
0
    # verify that nt.stat reports times in seconds, not ticks...

    import time
    tmpfile = 'tmpfile.tmp'
    f = open(tmpfile, 'w')
    f.close()
    t = time.time()
    mt = nt.stat(tmpfile).st_mtime
    nt.unlink(tmpfile)  # this deletes the file
    Assert(abs(t - mt) < 60, "time differs by too much " + str(abs(t - mt)))

    tmpfile = 'tmpfile.tmp'  # need to open it again since we deleted it with 'unlink'
    f = open(tmpfile, 'w')
    f.close()
    nt.chmod('tmpfile.tmp', 256)
    nt.chmod('tmpfile.tmp', 128)
    nt.unlink('tmpfile.tmp')


# utime tests
def test_utime():
    f = file('temp_file_does_not_exist.txt', 'w')
    f.close()
    import nt
    x = nt.stat('.')
    nt.utime('temp_file_does_not_exist.txt', (x[7], x[8]))
    y = nt.stat('temp_file_does_not_exist.txt')
    AreEqual(x[7], y[7])
    AreEqual(x[8], y[8])
    nt.unlink('temp_file_does_not_exist.txt')
예제 #16
0
파일: nt_test.py 프로젝트: 89sos98/main
def test_popen():
    # open a pipe just for reading...
    pipe_modes = [["ping 127.0.0.1", "r"],
                  ["ping 127.0.0.1"]]
    if is_cli:
        pipe_modes.append(["ping 127.0.0.1", ""])
        
    for args in pipe_modes:
        x = nt.popen(*args)
        text = x.read()
        Assert(text.lower().index('pinging') != -1)
        AreEqual(x.close(), None)

    # write to a pipe
    x = nt.popen('sort', 'w')
    x.write('hello\nabc\n')
    x.close()

    # bug 1146
    #x = nt.popen('sort', 'w')
    #x.write('hello\nabc\n')
    #AreEqual(x.close(), None)

    # once w/ default mode
    AssertError(ValueError, nt.popen, "ping 127.0.0.1", "a")

    # popen uses cmd.exe to run stuff -- at least sometimes
    dir_pipe = nt.popen('dir')
    dir_pipe.read()
    dir_pipe.close()

    # once w/ no mode
    stdin, stdout = nt.popen2('sort')
    stdin.write('hello\nabc\n')
    AreEqual(stdin.close(), None)
    AreEqual(stdout.read(), 'abc\nhello\n')
    AreEqual(stdout.close(), None)

    # bug 1146
    # and once w/ each mode
    #for mode in ['b', 't']:
    #    stdin, stdout = nt.popen2('sort', mode)
    #    stdin.write('hello\nabc\n')
    #    AreEqual(stdin.close(), None)
    #    AreEqual(stdout.read(), 'abc\nhello\n')
    #    AreEqual(stdout.close(), None)
        

    # popen3: once w/ no mode
    stdin, stdout, stderr = nt.popen3('sort')
    stdin.write('hello\nabc\n')
    AreEqual(stdin.close(), None)
    AreEqual(stdout.read(), 'abc\nhello\n')
    AreEqual(stdout.close(), None)
    AreEqual(stderr.read(), '')
    AreEqual(stderr.close(), None)

    # bug 1146
    # popen3: and once w/ each mode
    #for mode in ['b', 't']:
    #    stdin, stdout, stderr = nt.popen3('sort', mode)
    #    stdin.write('hello\nabc\n')
    #    AreEqual(stdin.close(), None)
    #    AreEqual(stdout.read(), 'abc\nhello\n')
    #    AreEqual(stdout.close(), None)
    #    AreEqual(stderr.read(), '')
    #    AreEqual(stderr.close(), None)
    
    tmpfile = 'tmpfile.tmp'
    f = open(tmpfile, 'w')
    f.close()
    nt.unlink(tmpfile)
    try:
        nt.chmod('tmpfile.tmp', 256)
    except Exception:
        pass #should throw when trying to access file deleted by unlink
    else:
        Assert(False,"Error! Trying to access file deleted by unlink should have thrown.")

    try:
        tmpfile = "tmpfile2.tmp"
        f = open(tmpfile, "w")
        f.write("testing chmod")
        f.close()
        nt.chmod(tmpfile, 256)
        AssertError(OSError, nt.unlink, tmpfile)
        nt.chmod(tmpfile, 128)
        nt.unlink(tmpfile)
        AssertError(IOError, file, tmpfile)
    finally:
        try:
            nt.chmod(tmpfile, 128)
            nt.unlink(tmpfile)
        except Exception, e:
            print "exc", e
예제 #17
0
파일: nt_test.py 프로젝트: 89sos98/main
def test_cp16413():
    tmpfile = 'tmpfile.tmp'
    f = open(tmpfile, 'w')
    f.close()
    nt.chmod(tmpfile, 0777)
    nt.unlink(tmpfile)
예제 #18
0
파일: nt_test.py 프로젝트: slide/main
def test_cp16413():
    tmpfile = "tmpfile.tmp"
    f = open(tmpfile, "w")
    f.close()
    nt.chmod(tmpfile, 0777)
    nt.unlink(tmpfile)
예제 #19
0
파일: nt_test.py 프로젝트: slide/main
    # verify that nt.stat reports times in seconds, not ticks...

    import time

    tmpfile = "tmpfile.tmp"
    f = open(tmpfile, "w")
    f.close()
    t = time.time()
    mt = nt.stat(tmpfile).st_mtime
    nt.unlink(tmpfile)  # this deletes the file
    Assert(abs(t - mt) < 60, "time differs by too much " + str(abs(t - mt)))

    tmpfile = "tmpfile.tmp"  # need to open it again since we deleted it with 'unlink'
    f = open(tmpfile, "w")
    f.close()
    nt.chmod("tmpfile.tmp", 256)
    nt.chmod("tmpfile.tmp", 128)
    nt.unlink("tmpfile.tmp")


# utime tests
def test_utime():
    f = file("temp_file_does_not_exist.txt", "w")
    f.close()
    import nt

    x = nt.stat(".")
    nt.utime("temp_file_does_not_exist.txt", (x[7], x[8]))
    y = nt.stat("temp_file_does_not_exist.txt")
    AreEqual(x[7], y[7])
    AreEqual(x[8], y[8])
예제 #20
0
    AreEqual(errno.errorcode[2], "ENOENT")


def test_cp24692():
    import errno, nt, stat
    dir_name = "cp24692_testdir"
    try:
        nt.mkdir(dir_name)
        nt.chmod(dir_name, stat.S_IREAD)
        try:
            nt.rmdir(dir_name)
        except WindowsError, e:
            pass
        AreEqual(e.errno, errno.EACCES)
    finally:
        nt.chmod(dir_name, stat.S_IWRITE)
        nt.rmdir(dir_name)


# TODO: this test needs to run against Dev10 builds as well
@skip("win32")
def test_cp22735():
    import System
    if System.Environment.Version.Major < 4:
        clr.AddReference("System.Core")
    from System import Func


#------------------------------------------------------------------------------
#--General coverage.  These need to be extended.
def test_xxsubtype_bench():
예제 #21
0
    def test_popen(self):
        # open a pipe just for reading...
        pipe_modes = [["ping 127.0.0.1 -n 1", "r"],
                    ["ping 127.0.0.1 -n 1"]]

        for args in pipe_modes:
            x = os.popen(*args)
            text = x.read()
            self.assertTrue(text.lower().index('pinging') != -1)
            self.assertEqual(x.close(), None)

        # write to a pipe
        x = os.popen('sort', 'w')
        x.write('hello\nabc\n')
        x.close()

        # bug 1146
        #x = os.popen('sort', 'w')
        #x.write('hello\nabc\n')
        #self.assertEqual(x.close(), None)

        # once w/ default mode
        self.assertRaises(ValueError, os.popen, "ping 127.0.0.1 -n 1", "a")

        # popen uses cmd.exe to run stuff -- at least sometimes
        dir_pipe = os.popen('dir')
        dir_pipe.read()
        dir_pipe.close()

        tmpfile = 'tmpfile.tmp'
        f = open(tmpfile, 'w')
        f.close()
        nt.unlink(tmpfile)
        try:
            nt.chmod('tmpfile.tmp', 256)
        except Exception:
            pass #should throw when trying to access file deleted by unlink
        else:
            self.assertTrue(False,"Error! Trying to access file deleted by unlink should have thrown.")

        try:
            tmpfile = "tmpfile2.tmp"
            f = open(tmpfile, "w")
            f.write("testing chmod")
            f.close()
            nt.chmod(tmpfile, 256)
            self.assertRaises(OSError, nt.unlink, tmpfile)
            nt.chmod(tmpfile, 128)
            nt.unlink(tmpfile)
            self.assertRaises(IOError, open, tmpfile)
        finally:
            try:
                nt.chmod(tmpfile, 128)
                nt.unlink(tmpfile)
            except Exception as e:
                print("exc", e)

        # verify that nt.stat reports times in seconds, not ticks...

        import time
        tmpfile = 'tmpfile.tmp'
        f = open(tmpfile, 'w')
        f.close()
        t = time.time()
        mt = nt.stat(tmpfile).st_mtime
        nt.unlink(tmpfile) # this deletes the file
        self.assertTrue(abs(t-mt) < 60, "time differs by too much " + str(abs(t-mt)))

        tmpfile = 'tmpfile.tmp' # need to open it again since we deleted it with 'unlink'
        f = open(tmpfile, 'w')
        f.close()
        nt.chmod('tmpfile.tmp', 256)
        nt.chmod('tmpfile.tmp', 128)
        nt.unlink('tmpfile.tmp')
예제 #22
0
def test_popen():
    # open a pipe just for reading...
    pipe_modes = [["ping 127.0.0.1 -n 1", "r"], ["ping 127.0.0.1 -n 1"]]
    if is_cli:
        pipe_modes.append(["ping 127.0.0.1 -n 1", ""])

    for args in pipe_modes:
        x = nt.popen(*args)
        text = x.read()
        Assert(text.lower().index('pinging') != -1)
        AreEqual(x.close(), None)

    # write to a pipe
    x = nt.popen('sort', 'w')
    x.write('hello\nabc\n')
    x.close()

    # bug 1146
    #x = nt.popen('sort', 'w')
    #x.write('hello\nabc\n')
    #AreEqual(x.close(), None)

    # once w/ default mode
    AssertError(ValueError, nt.popen, "ping 127.0.0.1 -n 1", "a")

    # popen uses cmd.exe to run stuff -- at least sometimes
    dir_pipe = nt.popen('dir')
    dir_pipe.read()
    dir_pipe.close()

    # once w/ no mode
    stdin, stdout = nt.popen2('sort')
    stdin.write('hello\nabc\n')
    AreEqual(stdin.close(), None)
    AreEqual(stdout.read(), 'abc\nhello\n')
    AreEqual(stdout.close(), None)

    # bug 1146
    # and once w/ each mode
    #for mode in ['b', 't']:
    #    stdin, stdout = nt.popen2('sort', mode)
    #    stdin.write('hello\nabc\n')
    #    AreEqual(stdin.close(), None)
    #    AreEqual(stdout.read(), 'abc\nhello\n')
    #    AreEqual(stdout.close(), None)

    # popen3: once w/ no mode
    stdin, stdout, stderr = nt.popen3('sort')
    stdin.write('hello\nabc\n')
    AreEqual(stdin.close(), None)
    AreEqual(stdout.read(), 'abc\nhello\n')
    AreEqual(stdout.close(), None)
    AreEqual(stderr.read(), '')
    AreEqual(stderr.close(), None)

    # bug 1146
    # popen3: and once w/ each mode
    #for mode in ['b', 't']:
    #    stdin, stdout, stderr = nt.popen3('sort', mode)
    #    stdin.write('hello\nabc\n')
    #    AreEqual(stdin.close(), None)
    #    AreEqual(stdout.read(), 'abc\nhello\n')
    #    AreEqual(stdout.close(), None)
    #    AreEqual(stderr.read(), '')
    #    AreEqual(stderr.close(), None)

    tmpfile = 'tmpfile.tmp'
    f = open(tmpfile, 'w')
    f.close()
    nt.unlink(tmpfile)
    try:
        nt.chmod('tmpfile.tmp', 256)
    except Exception:
        pass  #should throw when trying to access file deleted by unlink
    else:
        Assert(
            False,
            "Error! Trying to access file deleted by unlink should have thrown."
        )

    try:
        tmpfile = "tmpfile2.tmp"
        f = open(tmpfile, "w")
        f.write("testing chmod")
        f.close()
        nt.chmod(tmpfile, 256)
        AssertError(OSError, nt.unlink, tmpfile)
        nt.chmod(tmpfile, 128)
        nt.unlink(tmpfile)
        AssertError(IOError, file, tmpfile)
    finally:
        try:
            nt.chmod(tmpfile, 128)
            nt.unlink(tmpfile)
        except Exception, e:
            print "exc", e
예제 #23
0
def test_cp16413():
    tmpfile = 'tmpfile.tmp'
    f = open(tmpfile, 'w')
    f.close()
    nt.chmod(tmpfile, 0o777)
    nt.unlink(tmpfile)
예제 #24
0
파일: nt_test.py 프로젝트: 89sos98/main
    # verify that nt.stat reports times in seconds, not ticks...

    import time
    tmpfile = 'tmpfile.tmp'
    f = open(tmpfile, 'w')
    f.close()
    t = time.time()
    mt = nt.stat(tmpfile).st_mtime
    nt.unlink(tmpfile) # this deletes the file
    Assert(abs(t-mt) < 60, "time differs by too much " + str(abs(t-mt)))

    tmpfile = 'tmpfile.tmp' # need to open it again since we deleted it with 'unlink'
    f = open(tmpfile, 'w')
    f.close()
    nt.chmod('tmpfile.tmp', 256)
    nt.chmod('tmpfile.tmp', 128)
    nt.unlink('tmpfile.tmp')

 
# utime tests
def test_utime():
    f = file('temp_file_does_not_exist.txt', 'w')
    f.close()
    import nt
    x = nt.stat('.')
    nt.utime('temp_file_does_not_exist.txt', (x[7], x[8]))
    y = nt.stat('temp_file_does_not_exist.txt')
    AreEqual(x[7], y[7])
    AreEqual(x[8], y[8])
    nt.unlink('temp_file_does_not_exist.txt')
예제 #25
0
def test_popen():
    # open a pipe just for reading...
    pipe_modes = [["ping 127.0.0.1 -n 1", "r"], ["ping 127.0.0.1 -n 1"]]
    if is_cli:
        pipe_modes.append(["ping 127.0.0.1 -n 1", ""])

    for args in pipe_modes:
        x = nt.popen(*args)
        text = x.read()
        Assert(text.lower().index('pinging') != -1)
        AreEqual(x.close(), None)

    # write to a pipe
    x = nt.popen('sort', 'w')
    x.write('hello\nabc\n')
    x.close()

    # bug 1146
    #x = nt.popen('sort', 'w')
    #x.write('hello\nabc\n')
    #AreEqual(x.close(), None)

    # once w/ default mode
    AssertError(ValueError, nt.popen, "ping 127.0.0.1 -n 1", "a")

    # popen uses cmd.exe to run stuff -- at least sometimes
    dir_pipe = nt.popen('dir')
    dir_pipe.read()
    dir_pipe.close()

    # once w/ no mode
    stdin, stdout = nt.popen2('sort')
    stdin.write('hello\nabc\n')
    AreEqual(stdin.close(), None)
    AreEqual(stdout.read(), 'abc\nhello\n')
    AreEqual(stdout.close(), None)

    # bug 1146
    # and once w/ each mode
    #for mode in ['b', 't']:
    #    stdin, stdout = nt.popen2('sort', mode)
    #    stdin.write('hello\nabc\n')
    #    AreEqual(stdin.close(), None)
    #    AreEqual(stdout.read(), 'abc\nhello\n')
    #    AreEqual(stdout.close(), None)

    # popen3: once w/ no mode
    stdin, stdout, stderr = nt.popen3('sort')
    stdin.write('hello\nabc\n')
    AreEqual(stdin.close(), None)
    AreEqual(stdout.read(), 'abc\nhello\n')
    AreEqual(stdout.close(), None)
    AreEqual(stderr.read(), '')
    AreEqual(stderr.close(), None)

    # bug 1146
    # popen3: and once w/ each mode
    #for mode in ['b', 't']:
    #    stdin, stdout, stderr = nt.popen3('sort', mode)
    #    stdin.write('hello\nabc\n')
    #    AreEqual(stdin.close(), None)
    #    AreEqual(stdout.read(), 'abc\nhello\n')
    #    AreEqual(stdout.close(), None)
    #    AreEqual(stderr.read(), '')
    #    AreEqual(stderr.close(), None)

    tmpfile = 'tmpfile.tmp'
    f = open(tmpfile, 'w')
    f.close()
    nt.unlink(tmpfile)
    try:
        nt.chmod('tmpfile.tmp', 256)
    except Exception:
        pass  #should throw when trying to access file deleted by unlink
    else:
        Assert(
            False,
            "Error! Trying to access file deleted by unlink should have thrown."
        )

    try:
        tmpfile = "tmpfile2.tmp"
        f = open(tmpfile, "w")
        f.write("testing chmod")
        f.close()
        nt.chmod(tmpfile, 256)
        AssertError(OSError, nt.unlink, tmpfile)
        nt.chmod(tmpfile, 128)
        nt.unlink(tmpfile)
        AssertError(IOError, file, tmpfile)
    finally:
        try:
            nt.chmod(tmpfile, 128)
            nt.unlink(tmpfile)
        except Exception as e:
            print("exc", e)

    # verify that nt.stat reports times in seconds, not ticks...

    import time
    tmpfile = 'tmpfile.tmp'
    f = open(tmpfile, 'w')
    f.close()
    t = time.time()
    mt = nt.stat(tmpfile).st_mtime
    nt.unlink(tmpfile)  # this deletes the file
    Assert(abs(t - mt) < 60, "time differs by too much " + str(abs(t - mt)))

    tmpfile = 'tmpfile.tmp'  # need to open it again since we deleted it with 'unlink'
    f = open(tmpfile, 'w')
    f.close()
    nt.chmod('tmpfile.tmp', 256)
    nt.chmod('tmpfile.tmp', 128)
    nt.unlink('tmpfile.tmp')
예제 #26
0
파일: regressions.py 프로젝트: 89sos98/main
    AreEqual(errno.errorcode[2],
             "ENOENT")

def test_cp24692():
    import errno, nt, stat
    dir_name = "cp24692_testdir"
    try:
        nt.mkdir(dir_name)
        nt.chmod(dir_name, stat.S_IREAD)
        try:
            nt.rmdir(dir_name)
        except WindowsError, e:
            pass
        AreEqual(e.errno, errno.EACCES)
    finally:
        nt.chmod(dir_name, stat.S_IWRITE)
        nt.rmdir(dir_name)

# TODO: this test needs to run against Dev10 builds as well
@skip("win32")
def test_cp22735():
    import System
    if System.Environment.Version.Major < 4:
        clr.AddReference("System.Core")
    from System import Func

#------------------------------------------------------------------------------
#--General coverage.  These need to be extended.
def test_xxsubtype_bench():
    import xxsubtype
    AreEqual(type(xxsubtype.bench(xxsubtype, "bench")),