[TIP] Are extensions needed for coverage required?

Ned Batchelder ned at nedbatchelder.com
Tue Nov 13 04:54:14 PST 2012


BTW: this turns out to be a subtle interaction between vars() and trace 
functions, but is not a bug.  Be careful out there!

Here's the complete details: 
https://bitbucket.org/ned/coveragepy/issue/211/unhashable-type-dict-under-python-tracer

Here's the (closed) CPython ticket about it: 
http://bugs.python.org/issue7083

--Ned.

On 11/8/2012 9:57 AM, Ned Batchelder wrote:
> I'm taking this offline with Uri.  If something alarming about 
> coverage.py is revealed, I'll report back.
>
> --Ned.
>
> On 11/8/2012 8:09 AM, Uri Okrent wrote:
>> Ned Batchelder <ned <at> nedbatchelder.com> writes:
>>> program.  To reduce the burden, coverage.py has a trace function 
>>> written
>>> in C.  If for whatever reason you can't compile that C extension,
>>> coverage.py will fall back to a Python implementation, which is what
>>
>> Hi Ned, I think I may have found a bug in the python implementation, 
>> but I'm not
>> sure.  I normally run my unit tests through coverage.  I just wrote 
>> some code
>> and the tests were passing, but when I tried to run coverage the same 
>> tests
>> would fail.
>>
>> Here is the error:
>>
>>      criteria_set.add(active_criteria)
>> TypeError: unhashable type: 'dict'
>>
>> This seems impossible because the (rather squirrely) code in question 
>> is this:
>>
>> 144     criteria_set = set()
>> ...
>> 148             active_criteria = []
>> 149             for criterion in criteria_keys:
>> 150                 if criterion in selection_set:
>> 151 active_criteria.append(criteria[criterion])
>> 152                 else:
>> 153                     active_criteria.append(None)
>> 154             active_criteria = tuple(active_criteria)
>> 155             # add unique criteria set tuples to the list of 
>> criteria sets
>> 156             criteria_set.add(active_criteria)
>>
>> And of course, the tests pass unless I run them under coverage
>> (`env PYTHONPATH=. coverage run /usr/bin/unit2 discover -s test` vs.
>> `env PYTHONPATH=. /usr/bin/unit2 discover -s test`).
>>
>> First thing I tried was upgrading my version of coverage from 3.5.1 
>> to 3.5.3,
>> but that made no difference.  I did notice, during the installation 
>> the error
>> regarding the extension, and so because I'm anal, I went back and 
>> apt-get
>> install python-dev and then reinstalled coverage, and this time the
>> coverage.tracer extension was successfully built.
>>
>> Just for the heck of it I ran coverage again, and lo and behold, all 
>> my tests
>> are passing now.
>>
>> By the way, I really appreciate the awesome work you do with coverage.
>>
>> Thanks,
>>
>> Uri
>>
>>
>>
>> _______________________________________________
>> testing-in-python mailing list
>> testing-in-python at lists.idyll.org
>> http://lists.idyll.org/listinfo/testing-in-python
>>
>
>
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python
>




More information about the testing-in-python mailing list