Skip to content

Commit

Permalink
app: add no cover due to false positive
Browse files Browse the repository at this point in the history
This line is definitely being executed by
test_MetadataSyncJob_success_with_missing_key
but curiously it wasn't being shown as executed in our coverage
report.

Investigating, I discovered the following upstream bug:
https://bugs.python.org/issue2506

The cpython peephole optimizer is causing this line to report
as uncovered (here's a nice blog explaining this optimizer:
https://akaptur.com/blog/2014/08/02/the-cpython-peephole-optimizer-and-you/
this helpfully uses an example (see the section under "Complications arise"
where code is reported as uncovered due to peephole optimizations))
  • Loading branch information
redshiftzero authored and sssoleileraaa committed Dec 5, 2019
1 parent ebb9bf2 commit b7c2839
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion securedrop_client/api_jobs/downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ def call_api(self, api_client: API, session: Session) -> Any:
pub_key = source.key.get('public', None)
fingerprint = source.key.get('fingerprint', None)
if not pub_key or not fingerprint:
continue
# The below line needs to be excluded from the coverage computation
# as it will show as uncovered due to a cpython compiler optimziation.
# See: https://bugs.python.org/issue2506
continue # pragma: no cover
try:
self.gpg.import_key(source.uuid, pub_key, fingerprint)
except CryptoError:
Expand Down

0 comments on commit b7c2839

Please sign in to comment.