5

I am currently unit testing and was confused on the the below:

     Name                    Stmts   Miss Branch BrPart  Cover   Missing
     -------------------------------------------------------------------
     src/__init__.py             0      0      0      0   100%  
     src/__main__.py            33      2      8      3    88%   76-78, 50->exit, 57->exit, 70->76

what exactly does the 50-> exit mean?

2 Answers 2

4

50->exit means that line 50 could have then exited the function, but it never did. It is one of the branches missing from your execution.

Sign up to request clarification or add additional context in comments.

Comments

0

in my case it was in a structural pattern matching that had no default case, something like this:

def process_status(status):

  match status:

    case Status.ERROR:
      handle_error()

    case Status.SUCCESS:
      handle_success()

i was calling this function in my code with the status i wanted for different situations, so no need for a default case.

in the end i had to do the following, to have 100% coverage:

def process_status(status):

  match status:

    case Status.ERROR:
      handle_error()

    case Status.SUCCESS:
      handle_success()

    case _:  # pragma: no cover
      ...

hope it helps someone someday.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.