Issue #4662: os.tempnam(), os.tmpfile() and os.tmpnam() now raise a py3k

DeprecationWarning.
This commit is contained in:
Antoine Pitrou 2011-01-02 20:04:52 +00:00
parent f11d1832ec
commit b061461596
4 changed files with 99 additions and 70 deletions

View file

@ -38,11 +38,13 @@ class PosixTester(unittest.TestCase):
"getpid", "getpgrp", "getppid", "getuid",
]
for name in NO_ARG_FUNCTIONS:
posix_func = getattr(posix, name, None)
if posix_func is not None:
posix_func()
self.assertRaises(TypeError, posix_func, 1)
with warnings.catch_warnings():
warnings.filterwarnings("ignore", "", DeprecationWarning)
for name in NO_ARG_FUNCTIONS:
posix_func = getattr(posix, name, None)
if posix_func is not None:
posix_func()
self.assertRaises(TypeError, posix_func, 1)
if hasattr(posix, 'getresuid'):
def test_getresuid(self):
@ -290,14 +292,18 @@ class PosixTester(unittest.TestCase):
def test_tempnam(self):
if hasattr(posix, 'tempnam'):
self.assertTrue(posix.tempnam())
self.assertTrue(posix.tempnam(os.curdir))
self.assertTrue(posix.tempnam(os.curdir, 'blah'))
with warnings.catch_warnings():
warnings.filterwarnings("ignore", "tempnam", DeprecationWarning)
self.assertTrue(posix.tempnam())
self.assertTrue(posix.tempnam(os.curdir))
self.assertTrue(posix.tempnam(os.curdir, 'blah'))
def test_tmpfile(self):
if hasattr(posix, 'tmpfile'):
fp = posix.tmpfile()
fp.close()
with warnings.catch_warnings():
warnings.filterwarnings("ignore", "tmpfile", DeprecationWarning)
fp = posix.tmpfile()
fp.close()
def test_utime(self):
if hasattr(posix, 'utime'):