ufl team mailing list archive
-
ufl team
-
Mailing list archive
-
Message #01366
Re: [HG UFL] merge
Is it possible to combine this with a common file test.py that call
nosetests to run all tests? To make it uniform across the packages.
--
Anders
On Wed, Jun 17, 2009 at 10:35:07AM +0200, Martin Sandve Alnæs wrote:
> 1) sudo apt-get install python-nose
>
> 2) write files called "test_*.py"
>
> 3) implement functions "def test_*(): ..." in "test_*.py", use
> "assert" to check things
>
> 4) run "nosetests", and all tests are discovered
>
> You can also make packages called "test_*/" to have hierarchies of tests,
> with no extra lines for non-test code. The command nosetests can aid in
> some things like profiling and code coverage, but I've only just looked at
> it briefly. I particularly like test generators:
>
> def check_stuff(i, j):
> assert i + j > 2
>
> def test_stuff():
> for i in range(10):
> for j in range(10):
> yield check_stuff, i, j
>
> Which makes a range of tests calling check_stuff with different arguments.
> The above test gives 6 errors like these:
>
> martinal@martinal-xps:~/dev/fenics/ufl/test/newtests/test_exprbasics$ nosetests
> FFF.......FF........F...............................................................................
> ======================================================================
> FAIL: test_exprbasics.test_foo.test_stuff(0, 0)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File "/var/lib/python-support/python2.5/nose/case.py", line 182, in runTest
> self.test(*self.arg)
> File "/home/martinal/dev/fenics/ufl/test/newtests/test_exprbasics/test_foo.py",
> line 3, in check_stuff
> assert i + j > 2
> AssertionError
>
> ======================================================================
> FAIL: test_exprbasics.test_foo.test_stuff(0, 1)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File "/var/lib/python-support/python2.5/nose/case.py", line 182, in runTest
> self.test(*self.arg)
> File "/home/martinal/dev/fenics/ufl/test/newtests/test_exprbasics/test_foo.py",
> line 3, in check_stuff
> assert i + j > 2
> AssertionError
>
> ...
>
>
> Martin
>
>
>
> On Wed, Jun 17, 2009 at 10:00 AM, Kristian
> Oelgaard<k.b.oelgaard@xxxxxxxxxx> wrote:
> > Quoting Anders Logg <logg@xxxxxxxxx>:
> >
> >> On Tue, Jun 16, 2009 at 03:33:15PM +0200, UFL wrote:
> >> > One or more new changesets pushed to the primary ufl repository.
> >> > A short summary of the last three changesets is included below.
> >> >
> >> > changeset: 907:fe4e462aea075c22f750f0becf9733d5cf695ebe
> >> > tag: tip
> >> > parent: 906:e7bd26c2c52c50e49a7d7b7fc2b3f3f56decbd27
> >> > parent: 905:114de4a60b04da8323be66bc11827e9b90a24b1e
> >> > user: "Martin Sandve Alnæs <martinal@xxxxxxxxx>"
> >> > date: Tue Jun 16 15:33:14 2009 +0200
> >> > files:
> >> > description:
> >> > merge
> >> >
> >> >
> >> > changeset: 906:e7bd26c2c52c50e49a7d7b7fc2b3f3f56decbd27
> >> > parent: 904:d6d428a9474cff080ebeb2cd94a325351540dd1f
> >> > user: "Martin Sandve Alnæs <martinal@xxxxxxxxx>"
> >> > date: Tue Jun 16 15:32:52 2009 +0200
> >> > files: test/newtests/test_analysis/__init__.py
> >> test/newtests/test_compounds/__init__.py test/newtests/test_demos/__init__.py
> >> test/newtests/test_derivatives/__init__.py
> >> test/newtests/test_elements/__init__.py
> >> test/newtests/test_elements/test_cells.py
> >> test/newtests/test_elements/test_elements.py
> >> test/newtests/test_evaluation/__init__.py
> >> test/newtests/test_exprbasics/__init__.py
> >> test/newtests/test_indexing/__init__.py
> >> > description:
> >> > Added new test directory, planning to migrate to nose based unit tests.
> >>
> >> What is a nose based unit test?
> >
> > 'nose' is an extension of unittest and it's supposed to be easier to use.
> >
> > http://code.google.com/p/python-nose/
> >
> > Kristian
> >
> >
> >>
> >
> >
> > _______________________________________________
> > UFL-dev mailing list
> > UFL-dev@xxxxxxxxxx
> > http://fenics.org/mailman/listinfo/ufl-dev
> >
Attachment:
signature.asc
Description: Digital signature
Follow ups
References