summaryrefslogtreecommitdiff
path: root/Lib/test/test_posix.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_posix.py')
-rw-r--r--Lib/test/test_posix.py38
1 files changed, 18 insertions, 20 deletions
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index 5a0028c870..6b4272f636 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -1,11 +1,11 @@
"Test posix functions"
-from test.test_support import TestSkipped, TestFailed, TESTFN, run_suite
+from test import test_support
try:
import posix
except ImportError:
- raise TestSkipped, "posix is not available"
+ raise test_support.TestSkipped, "posix is not available"
import time
import os
@@ -19,11 +19,11 @@ class PosixTester(unittest.TestCase):
def setUp(self):
# create empty file
- fp = open(TESTFN, 'w+')
+ fp = open(test_support.TESTFN, 'w+')
fp.close()
def tearDown(self):
- os.unlink(TESTFN)
+ os.unlink(test_support.TESTFN)
def testNoArgFunctions(self):
# test posix functions which take no arguments and have
@@ -46,7 +46,7 @@ class PosixTester(unittest.TestCase):
def test_fstatvfs(self):
if hasattr(posix, 'fstatvfs'):
- fp = open(TESTFN)
+ fp = open(test_support.TESTFN)
try:
self.assert_(posix.fstatvfs(fp.fileno()))
finally:
@@ -54,7 +54,7 @@ class PosixTester(unittest.TestCase):
def test_ftruncate(self):
if hasattr(posix, 'ftruncate'):
- fp = open(TESTFN, 'w+')
+ fp = open(test_support.TESTFN, 'w+')
try:
# we need to have some data to truncate
fp.write('test')
@@ -65,7 +65,7 @@ class PosixTester(unittest.TestCase):
def test_dup(self):
if hasattr(posix, 'dup'):
- fp = open(TESTFN)
+ fp = open(test_support.TESTFN)
try:
fd = posix.dup(fp.fileno())
self.assert_(isinstance(fd, int))
@@ -75,8 +75,8 @@ class PosixTester(unittest.TestCase):
def test_dup2(self):
if hasattr(posix, 'dup2'):
- fp1 = open(TESTFN)
- fp2 = open(TESTFN)
+ fp1 = open(test_support.TESTFN)
+ fp2 = open(test_support.TESTFN)
try:
posix.dup2(fp1.fileno(), fp2.fileno())
finally:
@@ -84,7 +84,7 @@ class PosixTester(unittest.TestCase):
fp2.close()
def fdopen_helper(self, *args):
- fd = os.open(TESTFN, os.O_RDONLY)
+ fd = os.open(test_support.TESTFN, os.O_RDONLY)
fp2 = posix.fdopen(fd, *args)
fp2.close()
@@ -96,7 +96,7 @@ class PosixTester(unittest.TestCase):
def test_fstat(self):
if hasattr(posix, 'fstat'):
- fp = open(TESTFN)
+ fp = open(test_support.TESTFN)
try:
self.assert_(posix.fstat(fp.fileno()))
finally:
@@ -104,20 +104,20 @@ class PosixTester(unittest.TestCase):
def test_stat(self):
if hasattr(posix, 'stat'):
- self.assert_(posix.stat(TESTFN))
+ self.assert_(posix.stat(test_support.TESTFN))
def test_chdir(self):
if hasattr(posix, 'chdir'):
posix.chdir(os.curdir)
- self.assertRaises(OSError, posix.chdir, TESTFN)
+ self.assertRaises(OSError, posix.chdir, test_support.TESTFN)
def test_lsdir(self):
if hasattr(posix, 'lsdir'):
- self.assert_(TESTFN in posix.lsdir(os.curdir))
+ self.assert_(test_support.TESTFN in posix.lsdir(os.curdir))
def test_access(self):
if hasattr(posix, 'access'):
- self.assert_(posix.access(TESTFN, os.R_OK))
+ self.assert_(posix.access(test_support.TESTFN, os.R_OK))
def test_umask(self):
if hasattr(posix, 'umask'):
@@ -149,13 +149,11 @@ class PosixTester(unittest.TestCase):
def test_utime(self):
if hasattr(posix, 'utime'):
now = time.time()
- posix.utime(TESTFN, None)
- posix.utime(TESTFN, (now, now))
+ posix.utime(test_support.TESTFN, None)
+ posix.utime(test_support.TESTFN, (now, now))
def test_main():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(PosixTester))
- run_suite(suite)
+ test_support.run_unittest(PosixTester)
if __name__ == '__main__':
test_main()