Make changes suggested by Walter to use self.assert*() methods.

This commit is contained in:
Neal Norwitz 2003-02-17 22:40:31 +00:00
parent 3b8fb47fb0
commit 2ff51a87b3
1 changed files with 14 additions and 26 deletions

View File

@ -37,22 +37,17 @@ def testNoArgFunctions(self):
posix_func = getattr(posix, name, None) posix_func = getattr(posix, name, None)
if posix_func is not None: if posix_func is not None:
posix_func() posix_func()
try: self.assertRaises(TypeError, posix_func, 1)
posix_func(1)
except TypeError:
pass
else:
raise TestFailed, '%s should take no arguments' % name
def test_statvfs(self): def test_statvfs(self):
if hasattr(posix, 'statvfs'): if hasattr(posix, 'statvfs'):
posix.statvfs(os.curdir) self.assert_(posix.statvfs(os.curdir))
def test_fstatvfs(self): def test_fstatvfs(self):
if hasattr(posix, 'fstatvfs'): if hasattr(posix, 'fstatvfs'):
fp = open(TESTFN) fp = open(TESTFN)
try: try:
posix.fstatvfs(fp.fileno()) self.assert_(posix.fstatvfs(fp.fileno()))
finally: finally:
fp.close() fp.close()
@ -72,6 +67,7 @@ def test_dup(self):
fp = open(TESTFN) fp = open(TESTFN)
try: try:
fd = posix.dup(fp.fileno()) fd = posix.dup(fp.fileno())
self.assert_(isinstance(fd, int))
os.close(fd) os.close(fd)
finally: finally:
fp.close() fp.close()
@ -101,44 +97,36 @@ def test_fstat(self):
if hasattr(posix, 'fstat'): if hasattr(posix, 'fstat'):
fp = open(TESTFN) fp = open(TESTFN)
try: try:
posix.fstat(fp.fileno()) self.assert_(posix.fstat(fp.fileno()))
finally: finally:
fp.close() fp.close()
def test_stat(self): def test_stat(self):
if hasattr(posix, 'stat'): if hasattr(posix, 'stat'):
posix.stat(TESTFN) self.assert_(posix.stat(TESTFN))
def test_chdir(self): def test_chdir(self):
if hasattr(posix, 'chdir'): if hasattr(posix, 'chdir'):
posix.chdir(os.curdir) posix.chdir(os.curdir)
try: self.assertRaises(OSError, posix.chdir, TESTFN)
posix.chdir(TESTFN)
except OSError:
pass
else:
raise TestFailed, \
'should not be able to change directory to a file'
def test_lsdir(self): def test_lsdir(self):
if hasattr(posix, 'lsdir'): if hasattr(posix, 'lsdir'):
if TESTFN not in posix.lsdir(os.curdir): self.assert_(TESTFN in posix.lsdir(os.curdir))
raise TestFailed, \
'%s should exist in current directory' % TESTFN
def test_access(self): def test_access(self):
if hasattr(posix, 'access'): if hasattr(posix, 'access'):
if not posix.access(TESTFN, os.R_OK): self.assert_(posix.access(TESTFN, os.R_OK))
raise TestFailed, 'should have read access to: %s' % TESTFN
def test_umask(self): def test_umask(self):
if hasattr(posix, 'umask'): if hasattr(posix, 'umask'):
old_mask = posix.umask(0) old_mask = posix.umask(0)
self.assert_(isinstance(old_mask, int))
posix.umask(old_mask) posix.umask(old_mask)
def test_strerror(self): def test_strerror(self):
if hasattr(posix, 'strerror'): if hasattr(posix, 'strerror'):
posix.strerror(0) self.assert_(posix.strerror(0))
def test_pipe(self): def test_pipe(self):
if hasattr(posix, 'pipe'): if hasattr(posix, 'pipe'):
@ -148,9 +136,9 @@ def test_pipe(self):
def test_tempnam(self): def test_tempnam(self):
if hasattr(posix, 'tempnam'): if hasattr(posix, 'tempnam'):
posix.tempnam() self.assert_(posix.tempnam())
posix.tempnam(os.curdir) self.assert_(posix.tempnam(os.curdir))
posix.tempnam(os.curdir, 'blah') self.assert_(posix.tempnam(os.curdir, 'blah'))
def test_tmpfile(self): def test_tmpfile(self):
if hasattr(posix, 'tmpfile'): if hasattr(posix, 'tmpfile'):