summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_posix.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-05-20 21:35:26 (GMT)
committerBenjamin Peterson <benjamin@python.org>2008-05-20 21:35:26 (GMT)
commitee8712cda46338d223509cc5751fd36509ad3860 (patch)
treebb9d363b4276566415457980472001c7e3ec2bed /Lib/test/test_posix.py
parent6a654814ea3f3a918935762ffdcd33ae98e00278 (diff)
downloadcpython-ee8712cda46338d223509cc5751fd36509ad3860.zip
cpython-ee8712cda46338d223509cc5751fd36509ad3860.tar.gz
cpython-ee8712cda46338d223509cc5751fd36509ad3860.tar.bz2
#2621 rename test.test_support to test.support
Diffstat (limited to 'Lib/test/test_posix.py')
-rw-r--r--Lib/test/test_posix.py80
1 files changed, 40 insertions, 40 deletions
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index 57e9d15..f16abb2 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -1,11 +1,11 @@
"Test posix functions"
-from test import test_support
+from test import support
try:
import posix
except ImportError:
- raise test_support.TestSkipped("posix is not available")
+ raise 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(test_support.TESTFN, 'w+')
+ fp = open(support.TESTFN, 'w+')
fp.close()
def tearDown(self):
- os.unlink(test_support.TESTFN)
+ os.unlink(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(test_support.TESTFN)
+ fp = open(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(test_support.TESTFN, 'w+')
+ fp = open(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(test_support.TESTFN)
+ fp = open(support.TESTFN)
try:
fd = posix.dup(fp.fileno())
self.assert_(isinstance(fd, int))
@@ -80,8 +80,8 @@ class PosixTester(unittest.TestCase):
def test_dup2(self):
if hasattr(posix, 'dup2'):
- fp1 = open(test_support.TESTFN)
- fp2 = open(test_support.TESTFN)
+ fp1 = open(support.TESTFN)
+ fp2 = open(support.TESTFN)
try:
posix.dup2(fp1.fileno(), fp2.fileno())
finally:
@@ -89,7 +89,7 @@ class PosixTester(unittest.TestCase):
fp2.close()
def fdopen_helper(self, *args):
- fd = os.open(test_support.TESTFN, os.O_RDONLY)
+ fd = os.open(support.TESTFN, os.O_RDONLY)
fp2 = posix.fdopen(fd, *args)
fp2.close()
@@ -101,38 +101,38 @@ class PosixTester(unittest.TestCase):
def test_osexlock(self):
if hasattr(posix, "O_EXLOCK"):
- fd = os.open(test_support.TESTFN,
+ fd = os.open(support.TESTFN,
os.O_WRONLY|os.O_EXLOCK|os.O_CREAT)
- self.assertRaises(OSError, os.open, test_support.TESTFN,
+ self.assertRaises(OSError, os.open, support.TESTFN,
os.O_WRONLY|os.O_EXLOCK|os.O_NONBLOCK)
os.close(fd)
if hasattr(posix, "O_SHLOCK"):
- fd = os.open(test_support.TESTFN,
+ fd = os.open(support.TESTFN,
os.O_WRONLY|os.O_SHLOCK|os.O_CREAT)
- self.assertRaises(OSError, os.open, test_support.TESTFN,
+ self.assertRaises(OSError, os.open, support.TESTFN,
os.O_WRONLY|os.O_EXLOCK|os.O_NONBLOCK)
os.close(fd)
def test_osshlock(self):
if hasattr(posix, "O_SHLOCK"):
- fd1 = os.open(test_support.TESTFN,
+ fd1 = os.open(support.TESTFN,
os.O_WRONLY|os.O_SHLOCK|os.O_CREAT)
- fd2 = os.open(test_support.TESTFN,
+ fd2 = os.open(support.TESTFN,
os.O_WRONLY|os.O_SHLOCK|os.O_CREAT)
os.close(fd2)
os.close(fd1)
if hasattr(posix, "O_EXLOCK"):
- fd = os.open(test_support.TESTFN,
+ fd = os.open(support.TESTFN,
os.O_WRONLY|os.O_SHLOCK|os.O_CREAT)
- self.assertRaises(OSError, os.open, test_support.TESTFN,
+ self.assertRaises(OSError, os.open, support.TESTFN,
os.O_RDONLY|os.O_EXLOCK|os.O_NONBLOCK)
os.close(fd)
def test_fstat(self):
if hasattr(posix, 'fstat'):
- fp = open(test_support.TESTFN)
+ fp = open(support.TESTFN)
try:
self.assert_(posix.fstat(fp.fileno()))
finally:
@@ -140,16 +140,16 @@ class PosixTester(unittest.TestCase):
def test_stat(self):
if hasattr(posix, 'stat'):
- self.assert_(posix.stat(test_support.TESTFN))
+ self.assert_(posix.stat(support.TESTFN))
if hasattr(posix, 'chown'):
def test_chown(self):
# raise an OSError if the file does not exist
- os.unlink(test_support.TESTFN)
- self.assertRaises(OSError, posix.chown, test_support.TESTFN, -1, -1)
+ os.unlink(support.TESTFN)
+ self.assertRaises(OSError, posix.chown, support.TESTFN, -1, -1)
# re-create the file
- open(test_support.TESTFN, 'w').close()
+ open(support.TESTFN, 'w').close()
if os.getuid() == 0:
try:
# Many linux distros have a nfsnobody user as MAX_UID-2
@@ -158,29 +158,29 @@ class PosixTester(unittest.TestCase):
# This part of the test only runs when run as root.
# Only scary people run their tests as root.
ent = pwd.getpwnam('nfsnobody')
- posix.chown(test_support.TESTFN, ent.pw_uid, ent.pw_gid)
+ posix.chown(support.TESTFN, ent.pw_uid, ent.pw_gid)
except KeyError:
pass
else:
# non-root cannot chown to root, raises OSError
self.assertRaises(OSError, posix.chown,
- test_support.TESTFN, 0, 0)
+ support.TESTFN, 0, 0)
# test a successful chown call
- posix.chown(test_support.TESTFN, os.getuid(), os.getgid())
+ posix.chown(support.TESTFN, os.getuid(), os.getgid())
def test_chdir(self):
if hasattr(posix, 'chdir'):
posix.chdir(os.curdir)
- self.assertRaises(OSError, posix.chdir, test_support.TESTFN)
+ self.assertRaises(OSError, posix.chdir, support.TESTFN)
def test_lsdir(self):
if hasattr(posix, 'lsdir'):
- self.assert_(test_support.TESTFN in posix.lsdir(os.curdir))
+ self.assert_(support.TESTFN in posix.lsdir(os.curdir))
def test_access(self):
if hasattr(posix, 'access'):
- self.assert_(posix.access(test_support.TESTFN, os.R_OK))
+ self.assert_(posix.access(support.TESTFN, os.R_OK))
def test_umask(self):
if hasattr(posix, 'umask'):
@@ -201,24 +201,24 @@ class PosixTester(unittest.TestCase):
def test_utime(self):
if hasattr(posix, 'utime'):
now = time.time()
- posix.utime(test_support.TESTFN, None)
- self.assertRaises(TypeError, posix.utime, test_support.TESTFN, (None, None))
- self.assertRaises(TypeError, posix.utime, test_support.TESTFN, (now, None))
- self.assertRaises(TypeError, posix.utime, test_support.TESTFN, (None, now))
- posix.utime(test_support.TESTFN, (int(now), int(now)))
- posix.utime(test_support.TESTFN, (now, now))
+ posix.utime(support.TESTFN, None)
+ self.assertRaises(TypeError, posix.utime, support.TESTFN, (None, None))
+ self.assertRaises(TypeError, posix.utime, support.TESTFN, (now, None))
+ self.assertRaises(TypeError, posix.utime, support.TESTFN, (None, now))
+ posix.utime(support.TESTFN, (int(now), int(now)))
+ posix.utime(support.TESTFN, (now, now))
def test_chflags(self):
if hasattr(posix, 'chflags'):
- st = os.stat(test_support.TESTFN)
+ st = os.stat(support.TESTFN)
if hasattr(st, 'st_flags'):
- posix.chflags(test_support.TESTFN, st.st_flags)
+ posix.chflags(support.TESTFN, st.st_flags)
def test_lchflags(self):
if hasattr(posix, 'lchflags'):
- st = os.stat(test_support.TESTFN)
+ st = os.stat(support.TESTFN)
if hasattr(st, 'st_flags'):
- posix.lchflags(test_support.TESTFN, st.st_flags)
+ posix.lchflags(support.TESTFN, st.st_flags)
def test_environ(self):
for k, v in posix.environ.items():
@@ -226,7 +226,7 @@ class PosixTester(unittest.TestCase):
self.assertEqual(type(v), str)
def test_main():
- test_support.run_unittest(PosixTester)
+ support.run_unittest(PosixTester)
if __name__ == '__main__':
test_main()