[issue9315] The trace module lacks unit tests

Alexander Belopolsky report at bugs.python.org
Mon Sep 13 20:00:20 CEST 2010

Alexander Belopolsky <belopolsky at users.sourceforge.net> added the comment:

Eli, while porting your tests to py3k, I had to change expected output for list comprehension testing.  This is not really surprising because 3.x comprehensions differ from 2.x (they don't leak the loop variable anymore).

The difference between versions is most pronounced if a comprehension is spread in several lines:

l = [i for
     i in

The coverage of the above code in 2.x is

    1: l = [i for
            i in
   11:      range(10)]

but in 3.x, I get

   12: l = [i for
   10:      i in
    1:      range(10)]

Not surprisingly, 3.x coverage output for generators is the same as for comprehensions:

   12: l = list(i for
   10:          i in
    1:          range(10))

but in 2.x,

   12: l = list(i for
                i in
    1:          range(10))

In any case, I think the counts from the second and third line (10 and 1) are probably correct in 3.x, but I cannot explain 12 in the first line.


Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list