Yielded twisted failure marked as missed

Issue #440 resolved
Jakob de Maeyer created an issue


in this except clause (lines 75 through 81), we catch all exceptions, do some cleanup, and then reraise the exception by wrapping it in a twisted.Failure. The whole function is wrapped inside twisted's inlineCallbacks magic.

The coverage report (XML here, run with timid = True) shows the variable assignment in line 80 being hit but the subsequent line being missed. An accompanying test passes when line 81 is there and fails when I remove it, so I'm pretty sure it should indeed be hit.

I tried to create a minimal working example here but failed, sorry :/

Comments (8)

  1. Ned Batchelder repo owner

    Can you provide me with detailed instructions on how to run the test suite?

    BTW: I used scrapy yesterday, good stuff :)

  2. Jakob de Maeyer reporter

    Hey Ned, thanks for looking into it.

    I'm afraid I'm not too familiar with the test suite internals. I clone the repository, then run tox2 in it, or tox2 -- tests/test_crawl.py::CrawlTestCase::test_graceful_crawl_error_handling to run the relevant test only, after enabling timid mode in .coveragerc.

    btw I use coverage.py every day, also good stuff :)

  3. Jakob de Maeyer reporter

    Hey Ned! Yeah, the testvar line was to make sure that the yield statement really is hit. The code as it is in the current master works as expected (i.e. the failure is yielded). There is a test that explicitly tests that here but the line is reported as missed.

  4. Ned Batchelder repo owner

    @jdemaeyer Looks like this is a really simple thing that doesn't involve Twisted at all. I didn't understand your smaller test cases that didn't work. I think this boils down to: yields that are never returned to are marked as not executed:

    $ cat foo.py
    def gen():
        yield "yielded"
    $ coverage run --branch foo.py
    $ coverage report -m
    Name     Stmts   Miss Branch BrPart  Cover   Missing
    foo.py       5      2      0      0    60%   3-4

    When run without branch coverage, it's understood better:

    $ coverage run foo.py
    $ coverage report -m
    Name     Stmts   Miss  Cover   Missing
    foo.py       5      1    80%   4
  5. Log in to comment