<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
I can't set up your test scenario and try it myself, but it sounds
suspiciously like the Python peephole optimizer is getting in the way.&nbsp;
Dumping the .pyc files, though shows those two statements&nbsp; plain and
simple, either with the e+1 or the original e, so I'm not sure what
could be affecting the coverage measurement.<br>
<br>
--Ned.<br>
<br>
Ondrej Certik wrote:
<blockquote
 cite="mid:85b5c3130806241550q54a9776ageb6ebad8bafe70fc@mail.gmail.com"
 type="cite">
  <pre wrap="">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 <a class="moz-txt-link-freetext" href="http://hg.sympy.org/sympy">http://hg.sympy.org/sympy</a>
$ 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 &lt;rev unknown&gt;

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
  </pre>
  <blockquote type="cite">
    <pre wrap="">      assert 2 == 1
    </pre>
  </blockquote>
  <pre wrap=""><!---->         +  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 &lt;rev unknown&gt;

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
  </pre>
  <blockquote type="cite">
    <pre wrap="">      assert 2 == 1
    </pre>
  </blockquote>
  <pre wrap=""><!---->         +  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

_______________________________________________
testing-in-python mailing list
<a class="moz-txt-link-abbreviated" href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.org</a>
<a class="moz-txt-link-freetext" href="http://lists.idyll.org/listinfo/testing-in-python">http://lists.idyll.org/listinfo/testing-in-python</a>



  </pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">-- 
Ned Batchelder, <a class="moz-txt-link-freetext" href="http://nedbatchelder.com">http://nedbatchelder.com</a>
</pre>
</body>
</html>