[TIP] replacing "break" with "continue" causes line to not be covered w/ coverage.py
Laurens Van Houtven
_ at lvh.cc
Sat Jul 2 14:22:57 PDT 2011
Hey.
I'm experiencing some strange behavior. I have a loop, and when I continue
to the next element on some condition, it told me that line wasn't covered.
Then, I put a pdb.set_trace() in, and I saw that it was, in fact, being run.
I put a raise ValueError() instead of that "continue", and it raised. I
replaced "continue" with "break", and now coverage.py thinks the line is
covered.
What could be going on? Here's the diff:
=== modified file 'twisted/positioning/nmea.py'
--- twisted/positioning/nmea.py 2011-07-02 18:40:44 +0000
+++ twisted/positioning/nmea.py 2011-07-02 21:14:31 +0000
@@ -552,7 +552,7 @@
prn, azimuth, elevation, snr = values
if prn is None or snr is None:
- break
+ continue
satellite = base.Satellite(prn, azimuth, elevation, snr)
self._sentenceData['_partialBeaconInformation'].beacons.add(satellite)
The code lives in lp:~lvh/twisted/positioning.
The strange thing is even trial --coverage (which is unrelated to
coverage.py...) thinks it's not covered. How can that be?
cheers
lvh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20110702/67d46dda/attachment.htm>
More information about the testing-in-python
mailing list