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

A few minor fixes #224

Merged
merged 4 commits into from
Jul 24, 2019
Merged

A few minor fixes #224

merged 4 commits into from
Jul 24, 2019

Conversation

bluetech
Copy link
Member

Please see the commit messages.

`defaults` is the default values e.g. `1` in `foo=1`. It's just used to
find the offset of the kwargs, but the code reused the name which made
me scratch my head for a minute.
@codecov-io
Copy link

codecov-io commented Jul 21, 2019

Codecov Report

Merging #224 into master will decrease coverage by 0.8%.
The diff coverage is 83.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #224      +/-   ##
==========================================
- Coverage   93.88%   93.08%   -0.81%     
==========================================
  Files           9       14       +5     
  Lines        1129     1677     +548     
  Branches       21      117      +96     
==========================================
+ Hits         1060     1561     +501     
- Misses         66      101      +35     
- Partials        3       15      +12
Impacted Files Coverage Δ
testing/test_multicall.py 99.27% <100%> (+0.65%) ⬆️
src/pluggy/hooks.py 94.35% <80%> (ø)
src/pluggy/_tracing.py 100% <0%> (ø)
src/pluggy/__init__.py 75% <0%> (ø)
src/pluggy/manager.py 94.62% <0%> (ø)
src/pluggy/callers.py 79.2% <0%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8aa5592...95dd65f. Read the comment docs.

Copy link
Contributor

@goodboy goodboy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made a few suggestions @bluetech but looks good so far!
Thanks for the effort 👍



hookspec = HookspecMarker("example")
hookimpl = HookimplMarker("example")


def test_uses_copy_of_methods():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bluetech you're saying this test was broken for you?

I don't recall seeing that issue but we are planning on removing all of this as per #59 anyway.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test has a typo return instead of assert. If the typo is fixed, it fails. Actually the methods are not copied. Since I think the test is ill conceived and tests deprecated functionality, I opted to just remove it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

@@ -777,7 +777,9 @@ using the :py:meth:`pluggy._HookCaller.call_historic()` method:


# call with history; no results returned
pm.hook.myhook.call_historic(config=config, args=sys.argv, result_callback=callback)
pm.hook.myhook.call_historic(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

@@ -135,6 +135,7 @@ def parse_hookimpl_opts(self, plugin, name):
res = getattr(method, self.project_name + "_impl", None)
except Exception:
res = {}
normalize_hookimpl_opts(res)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm maybe we could do the same single conditional block like at line 111 at the end of this method?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't figure out what "same single conditional block like at line 111" refers to, can you explain more?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh sorry my local version of the code is out of date. So basically a block like this at the end of this method which does the normalization if res != None. This might also mean we can remove line 116? A brief look shows this is the only place that method is used internally so I think we might be ok with that change.

@RonnyPfannschmidt @nicoddemus do we use that function in pytest for some reason?

Copy link
Contributor

@goodboy goodboy Jul 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't look like it. @bluetech I think you should be fine to factor that call into parse_hookimpl_opts() and remove it from 116.

Probably makes sense to have normalization be atomic with the parsing steps but lets see what others think.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a test test_parse_hookimpl_override which overrides parse_hookimpl_opts, returns {} and expects it to work. I did not consider this option so the premise of my commit was wrong. I removed it.

@@ -171,9 +171,9 @@ def varnames(func):
args, defaults = tuple(spec.args), spec.defaults
if defaults:
index = -len(defaults)
args, defaults = args[:index], tuple(args[index:])
args, kwargs = args[:index], tuple(args[index:])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed that this name is better.

The test passes invalid values to the instance (it does not takes
functions, it takes HookImpls). The test fails, but it accidentally used
`return` instead of `assert` so it wasn't visible.

Since what is being tested is evidently unimportant and legacy, just
remove it.
It doesn't take `**kwargs` but an argument `kwargs`.
Copy link
Contributor

@goodboy goodboy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me. I am still interested if we can factor that normalization step into the parse method. Despite there being a test for overriding it I'm betting no client code is actually doing that. Might be worth creating a new issue to play with?

Copy link
Member

@asottile asottile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@goodboy goodboy merged commit a1c6c35 into pytest-dev:master Jul 24, 2019
@bluetech bluetech deleted the fixes1 branch June 28, 2020 08:40
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

Successfully merging this pull request may close these issues.

4 participants