summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_os.py74
-rw-r--r--Lib/test/test_posix.py13
2 files changed, 1 insertions, 86 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index 05932f5..0fe7382 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -8,9 +8,6 @@ import warnings
import sys
from test import test_support
-warnings.filterwarnings("ignore", "tempnam", RuntimeWarning, __name__)
-warnings.filterwarnings("ignore", "tmpnam", RuntimeWarning, __name__)
-
# Tests creating TESTFN
class FileTests(unittest.TestCase):
def setUp(self):
@@ -24,76 +21,6 @@ class FileTests(unittest.TestCase):
self.assert_(os.access(test_support.TESTFN, os.W_OK))
-class TemporaryFileTests(unittest.TestCase):
- def setUp(self):
- self.files = []
- os.mkdir(test_support.TESTFN)
-
- def tearDown(self):
- for name in self.files:
- os.unlink(name)
- os.rmdir(test_support.TESTFN)
-
- def check_tempfile(self, name):
- # make sure it doesn't already exist:
- self.failIf(os.path.exists(name),
- "file already exists for temporary file")
- # make sure we can create the file
- open(name, "w")
- self.files.append(name)
-
- def test_tempnam(self):
- if not hasattr(os, "tempnam"):
- return
- warnings.filterwarnings("ignore", "tempnam", RuntimeWarning,
- r"test_os$")
- self.check_tempfile(os.tempnam())
-
- name = os.tempnam(test_support.TESTFN)
- self.check_tempfile(name)
-
- name = os.tempnam(test_support.TESTFN, "pfx")
- self.assertEqual(os.path.basename(name)[:3], "pfx")
- self.check_tempfile(name)
-
- def test_tmpfile(self):
- if not hasattr(os, "tmpfile"):
- return
- fp = os.tmpfile()
- fp.write(b"foobar")
- fp.seek(0)
- s = fp.read()
- fp.close()
- self.assertEquals(s, b"foobar")
-
- def test_tmpnam(self):
- import sys
- if not hasattr(os, "tmpnam"):
- return
- warnings.filterwarnings("ignore", "tmpnam", RuntimeWarning,
- r"test_os$")
- name = os.tmpnam()
- if sys.platform in ("win32",):
- # The Windows tmpnam() seems useless. From the MS docs:
- #
- # The character string that tmpnam creates consists of
- # the path prefix, defined by the entry P_tmpdir in the
- # file STDIO.H, followed by a sequence consisting of the
- # digit characters '0' through '9'; the numerical value
- # of this string is in the range 1 - 65,535. Changing the
- # definitions of L_tmpnam or P_tmpdir in STDIO.H does not
- # change the operation of tmpnam.
- #
- # The really bizarre part is that, at least under MSVC6,
- # P_tmpdir is "\\". That is, the path returned refers to
- # the root of the current drive. That's a terrible place to
- # put temp files, and, depending on privileges, the user
- # may not even be able to open a file in the root directory.
- self.failIf(os.path.exists(name),
- "file already exists for temporary file")
- else:
- self.check_tempfile(name)
-
# Test attributes on return values from os.*stat* family.
class StatAttributeTests(unittest.TestCase):
def setUp(self):
@@ -483,7 +410,6 @@ if sys.platform != 'win32':
def test_main():
test_support.run_unittest(
FileTests,
- TemporaryFileTests,
StatAttributeTests,
EnvironTests,
WalkTests,
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index 22ec748..3569453 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -29,7 +29,7 @@ class PosixTester(unittest.TestCase):
# test posix functions which take no arguments and have
# no side-effects which we need to cleanup (e.g., fork, wait, abort)
NO_ARG_FUNCTIONS = [ "ctermid", "getcwd", "getcwdu", "uname",
- "times", "getloadavg", "tmpnam",
+ "times", "getloadavg",
"getegid", "geteuid", "getgid", "getgroups",
"getpid", "getpgrp", "getppid", "getuid",
]
@@ -171,17 +171,6 @@ class PosixTester(unittest.TestCase):
os.close(reader)
os.close(writer)
- def test_tempnam(self):
- if hasattr(posix, 'tempnam'):
- self.assert_(posix.tempnam())
- self.assert_(posix.tempnam(os.curdir))
- self.assert_(posix.tempnam(os.curdir, 'blah'))
-
- def test_tmpfile(self):
- if hasattr(posix, 'tmpfile'):
- fp = posix.tmpfile()
- fp.close()
-
def test_utime(self):
if hasattr(posix, 'utime'):
now = time.time()