[Python-checkins] python/dist/src/Lib/test test_posix.py,NONE,1.1

Walter Dörwald walter@livinglogic.de
Mon, 17 Feb 2003 19:37:55 +0100


nnorwitz@users.sourceforge.net wrote:

> Update of /cvsroot/python/python/dist/src/Lib/test
> In directory sc8-pr-cvs1:/tmp/cvs-serv21363/Lib/test
> 
> Added Files:
> 	test_posix.py 
> Log Message:
> Added test_posix (hopefully it works on Windows).
> Remove PyArg_ParseTuple() for methods which take no args,
> use METH_NOARGS instead
 > [...]
>                 try:
>                     posix_func(1)
>                 except TypeError:
>                     pass
>                 else:
>                     raise TestFailed, '%s should take no arguments' % name

Why not write this as
self.assertRaises(TypeError, posix_func, 1)
? The same could be done for test_chdir()

>     def test_lsdir(self):
>         if hasattr(posix, 'lsdir'):
>             if TESTFN not in posix.lsdir(os.curdir):
>                 raise TestFailed, \
>                       '%s should exist in current directory' % TESTFN

This could be
self.assert_(TESTFN in posix.lsdir(os.curdir))

>     def test_access(self):
>         if hasattr(posix, 'access'):
>             if not posix.access(TESTFN, os.R_OK):
>                 raise TestFailed, 'should have read access to: %s' % TESTFN

This could be
self.assert_(posix.access(TESTFN, os.R_OK))

Bye,
    Walter Dörwald