Exclude blocks of code (not starting with :)

Issue #450 duplicate
notsqrt created an issue

Hi!

I have a use case for something like this:

@unittest.skip
class Test(unittest.TestCase):
    # pass

and I want to exclude these lines.

For the moment, block exclusion assumes that the starting line ends with : and that the block is indented.

Here, we need to check lines starting with @ and exclude the next block without additional indentation.

With the current code, only the @unittest.skip gets excluded if I put it in the exclude_lines parameter.

Is that feasable ?

Thanks !

Comments (5)

  1. Ned Batchelder repo owner

    It sounds like you want a pragma on the decorator to apply to the whole function, like #131 describes.

    On a separate point, I'm curious why you want to exclude these tests?

  2. notsqrt reporter

    Yes, it's similar to #131 in terms of implementation.

    I want to exclude these lines because I think it's not the job of coverage to tell me that these tests are not run ! It's the job of the test runner that counts and reports skipped tests. When these lines are excluded, it no longer pollutes the list of files with low coverage, making for an easier review of them.

  3. Log in to comment