[TIP] figleaf + py.test doesn't work sometimes

Ondrej Certik ondrej at certik.cz
Tue Jun 24 15:50:48 PDT 2008


Hi,

figleaf incorrectly reports some lines as not executed, while they
were in fact executed. I have no idea where the bug is.

How to reproduce:

$ hg clone http://hg.sympy.org/sympy
$ cd sympy
$ hg up 53ea24e1700c
$ figleaf /usr/bin/py.test sympy/series/
[...]
sympy/series/tests/test_limits.py[5] .....
[...]
$ figleaf2html
$ epiphany html/index.html

go to "sympy/sympy/series/limits.py" and observe:

  96.     def doit(self):
  97.         e, z, z0, dir = self.args
  98.         return limit(e, z, z0, dir)

that 97, 98 lines are red. So I thought these two lines are untested,
but in fact they are tested, as can be proven by applying this patch:

diff --git a/sympy/series/limits.py b/sympy/series/limits.py
--- a/sympy/series/limits.py
+++ b/sympy/series/limits.py
@@ -95,7 +95,7 @@ class Limit(Basic, NoRelMeths, ArithMeth

     def doit(self):
         e, z, z0, dir = self.args
-        return limit(e, z, z0, dir)
+        return limit(e+1, z, z0, dir)

     def tostr(self, level=0):
         e, z, z0, dir = self.args


then:

$ rm .figleaf
$ figleaf /usr/bin/py.test sympy/series/
============================= test process starts ==============================
executable:   /usr/bin/python  (2.5.2-final-0)
using py lib: /usr/lib/python2.5/site-packages/py <rev unknown>

sympy/series/tests/test_demidovich.py[15] ............fff
sympy/series/tests/test_gruntz.py[20] ...................f
sympy/series/tests/test_limits.py[5] ....F
sympy/series/tests/test_nseries.py[53]
.....................................................
sympy/series/tests/test_order.py[21] ....................f
sympy/series/tests/test_oseries.py[10] ..........
sympy/series/tests/test_series.py[39] ...............................ffffffff

________________________________________________________________________________
____________________________ entrypoint: test_Limit ____________________________

    def test_Limit():
        assert Limit(sin(x)/x, x, 0) != 1
        assert str(Limit(1/x, x, 0)) == "Limit(1/x, x, 0, dir='+')" != 1
E       assert Limit(sin(x)/x, x, 0).doit() == 1
>       assert 2 == 1
         +  where 2 = Limit(1/x*sin(x), x, 0, dir='+').doit()
         +    where Limit(1/x*sin(x), x, 0, dir='+') = Limit((sin(x) / x), x, 0)
         +      where sin(x) = sin(x)

[/tmp/sympy/sympy/series/tests/test_limits.py:45]
________________________________________________________________________________
======= tests finished: 149 passed, 13 xfail, 1 failed in 149.29 seconds =======
DO *NOT* COMMIT!


The funny thing is that figleaf still shows that doit() were not
executed. However, if one does:

$ figleaf /usr/bin/py.test sympy/series/tests/test_limits.py
============================= test process starts ==============================
executable:   /usr/bin/python  (2.5.2-final-0)
using py lib: /usr/lib/python2.5/site-packages/py <rev unknown>

sympy/series/tests/test_limits.py[5] ....F

________________________________________________________________________________
____________________________ entrypoint: test_Limit ____________________________

    def test_Limit():
        assert Limit(sin(x)/x, x, 0) != 1
        assert str(Limit(1/x, x, 0)) == "Limit(1/x, x, 0, dir='+')" != 1
E       assert Limit(sin(x)/x, x, 0).doit() == 1
>       assert 2 == 1
         +  where 2 = Limit(1/x*sin(x), x, 0, dir='+').doit()
         +    where Limit(1/x*sin(x), x, 0, dir='+') = Limit((sin(x) / x), x, 0)
         +      where sin(x) = sin(x)

[/tmp/sympy/sympy/series/tests/test_limits.py:45]
________________________________________________________________________________
============== tests finished: 4 passed, 1 failed in 4.72 seconds ==============
$ figleaf2html

now it reports those two lines as executed....

I wonder what is going on here. Any tips are appreciated.

Ondrej



More information about the testing-in-python mailing list