Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Statements "return (" have no coverage data #101

Open
matveypashkovskiy opened this issue Mar 29, 2021 · 2 comments
Open

Statements "return (" have no coverage data #101

matveypashkovskiy opened this issue Mar 29, 2021 · 2 comments

Comments

@matveypashkovskiy
Copy link
Contributor

Here is an example from a project:

return (
  df
  .withColumnRenamed("a", "b")
)

if the code is modified to:

return self.reset(
  df
  .withColumnRenamed("a", "b")
)

no tests will be found for the change as DB contains no mapping info about return ( line.

Any ideas on how to fix it? Any magic pytest-cov flag maybe?

@guotin
Copy link
Contributor

guotin commented Mar 30, 2021

I tried to replicate a similar situation and ran into a weird situation. If I have some similar code and run the coverage collection with pytest --cov=. --cov-context=test and check how the coverage report looks, I get this:

cov_problem

So no test is recorded for the return key because there is no context for that line. But if change the source code like you did, the testname gets recorded:

cov_problem2

I don't think I can come up with a fix for this with any pytest-cov flag. You can also check what kind of contexts your program has by setting

[html]
show_contexts = True

and checking the html report produced by coverage html

@guotin
Copy link
Contributor

guotin commented Mar 30, 2021

Update: for my example, this seems to be python version specific. The above situation is with 3.6.6 and with 3.8.5 the testname is recorded for the line in both cases. I had pytest-cov 2.11.1 and coverage 5.5 during both.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants