Patch for using nose with tests

2 views
Skip to first unread message

Kurt Smith

unread,
May 8, 2009, 12:21:18 AM5/8/09
to f2py-dev
Here's a working patch to the test modules in fparser. There seems to
be redundancy in the test modules (test_parser.py &
test_Fortran2003.py are duplicated), but I made corrections to all 4
files to work with nose.

Assuming nose is installed, and 'nosetests' is somewhere on the path,
the following will run all the tests from the command line, assuming
the pwd is f2py/fparser:

$ nosetests --include=tests --include=check

The 2 'include's are to run everything in the tests dir and to run all
functions that have 'check' in the name (by default only
functions/classes with 'test' in the name will be run).

All tests pass.

Kurt

tests-nose.patch

Pearu Peterson

unread,
May 8, 2009, 2:55:36 AM5/8/09
to F2PY Developers
Hi,

On May 8, 7:21 am, Kurt Smith <kwmsm...@gmail.com> wrote:
> Here's a working patch to the test modules in fparser.  There seems to
> be redundancy in  the test modules (test_parser.py &
> test_Fortran2003.py are duplicated), but I made corrections to all 4
> files to work with nose.

All duplications should be removed and let's have all tests in tests/
directory.

> Assuming nose is installed, and 'nosetests' is somewhere on the path,
> the following will run all the tests from the command line, assuming
> the pwd is f2py/fparser:
>
> $ nosetests --include=tests --include=check
>
> The 2 'include's are to run everything in the tests dir and to run all
> functions that have 'check' in the name (by default only
> functions/classes with 'test' in the name will be run).
>
> All tests pass.

Few comments about the patch:
First, it looks good. Second, use TestCase instead of
unittest.TestCase.
Third, it is possible to write tests without importing nose in the
test file. The current tests use `assert_equal(a, b)` that can be
replaced with `assert a==b` (in future) which removes nose dependency.
Finally, often we don't even need TestCase and hence unittest
dependency
can be also removed (in future). TestCase is useful when setting up/
tearing down
tests but nose supports these tasks via defining special functions to
the
test module.

Feel free to commit your patches to the repository when all tests
pass.
I know that some projects demand the revisions of all patches by other
developers before the commit, but I feel that for us it is an overkill
when
the number of developers is small. So, just commit and we can review
patches within the repository when needed.

Thanks,
Pearu
Reply all
Reply to author
Forward
0 new messages