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
Milestone

Comments

@davidszotten
Copy link
Contributor

@davidszotten davidszotten commented Dec 20, 2019

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 label Dec 20, 2019
@nedbat

This comment has been minimized.

Copy link
Owner

@nedbat 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

This comment has been minimized.

Copy link
Contributor Author

@davidszotten davidszotten commented Dec 22, 2019

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

This comment has been minimized.

Copy link
Owner

@nedbat 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

This comment has been minimized.

Copy link
Contributor Author

@davidszotten davidszotten commented Dec 22, 2019

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

This comment has been minimized.

Copy link
Contributor Author

@davidszotten davidszotten commented Dec 27, 2019

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

nedbat added a commit that referenced this issue Dec 27, 2019
@nedbat

This comment has been minimized.

Copy link
Owner

@nedbat nedbat commented Dec 27, 2019

I added a warning for this case in 16ef35f.

@nedbat nedbat closed this Dec 27, 2019
@nedbat nedbat added the fixed label Dec 27, 2019
@nedbat

This comment has been minimized.

Copy link
Owner

@nedbat 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
Projects
None yet
2 participants
You can’t perform that action at this time.