[TIP] Are extensions needed for coverage required?
Uri Okrent
uokrent at gmail.com
Thu Nov 8 05:09:04 PST 2012
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
More information about the testing-in-python
mailing list