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

context labelled differently #901

Closed
davidszotten opened this issue Dec 20, 2019 · 7 comments
Closed

context labelled differently #901

davidszotten opened this issue Dec 20, 2019 · 7 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@davidszotten
Copy link
Contributor

pytest --cov=test_foo --cov-context=test; coverage report --contexts=test_foo

environ identical to #900

setting dynamic_context = test_function in .coveragerc, i get context reported as
test_foo.test_foo

but without that setting, the context is reported as
test_foo.py::test_foo|run

@davidszotten davidszotten added the bug Something isn't working label Dec 20, 2019
@nedbat
Copy link
Owner

nedbat commented Dec 21, 2019

There's no single definition of what the context labels should be. The built-in "test_function" uses one style, and the pytest plugin uses another more elaborate style.

I hadn't thought much about the situation where two different mechanisms are trying to set contexts. Maybe there could be some error handling or warnings in that case?

@nedbat nedbat added this to the 5.0.1 milestone Dec 22, 2019
@davidszotten
Copy link
Contributor Author

a warning sounds reasonable to me. happy to have a first pass at a pr (warning if setting a context means overriding on already set). does coverage already have a warnings system you could point me to?

@nedbat
Copy link
Owner

nedbat commented Dec 22, 2019

There is a warnings facility, for example:

if self.config.note:
self._warn("The '[run] note' setting is no longer supported.")

But off the top of my head, I'm not sure how this will work. pytest-cov sets a context by calling Coverage.switch_context, which I guess could warn if the coverage config already had a setting? We have to be careful of unintended interactions.

@davidszotten
Copy link
Contributor Author

ah, i thought the api might have been enter/exit context

perhaps this is more of a documentation issue, e.g. recommending test runnings/plugins over dynamic_context = test_function

maybe most of my confusion is from following the alphas, and picking up the dynamic_context setting before there was support in pytest-cov

@nedbat nedbat modified the milestones: 5.0.1, 5.0.2 Dec 22, 2019
@davidszotten
Copy link
Contributor Author

@nedbat having re-read the docs i'm happy to close this unless you think any action is needed

@nedbat
Copy link
Owner

nedbat commented Dec 27, 2019

I added a warning for this case in 16ef35f.

@nedbat nedbat closed this as completed Dec 27, 2019
@nedbat nedbat added the fixed label Dec 27, 2019
@nedbat
Copy link
Owner

nedbat commented Jan 5, 2020

This is now available in coverage 5.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

2 participants