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

Deprecate _Result.excinfo #155

Closed
wants to merge 3 commits into from

Conversation

goodboy
Copy link
Contributor

@goodboy goodboy commented May 24, 2018

Resolves #86

@goodboy goodboy changed the title Deprecate _Results.excinfo Deprecate _Result.excinfo May 24, 2018
"""Get the exception info for this hook call (DEPRECATED in favor of
``get_result()``).
"""
msg = 'Use `get_result()` which raises the underlying exception'
Copy link
Member

Choose a reason for hiding this comment

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

i believe for clarity of the warning the property should be referenced in the text somehow

Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

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

I agree with @RonnyPfannschmidt's suggestion, other than that LGTM.

@goodboy
Copy link
Contributor Author

goodboy commented May 25, 2018

@RonnyPfannschmidt @nicoddemus pushed the change hopefully it's good enough 👍

@goodboy
Copy link
Contributor Author

goodboy commented May 27, 2018

@nicoddemus what's the recommended way to make CI happy here?

I kind of want to keep failure on unexpected deprecation warnings but we also can't wrap pytest runs with pytest.deprecated_call()?

@RonnyPfannschmidt
Copy link
Member

@tgoodlet i beleive we need to set up pytest awrning filters in a way that we dont error on plugy warnings and make a pytest release where we dont fail anymore

@nicoddemus
Copy link
Member

I think @RonnyPfannschmidt's suggestion is on point. 👍

@goodboy
Copy link
Contributor Author

goodboy commented Jul 26, 2018

@nicoddemus gonna rebase this and put in a newsfragment using the new towncrier stuff 👍

@goodboy
Copy link
Contributor Author

goodboy commented Jul 26, 2018

@nicoddemus @RonnyPfannschmidt also do you both mind checking I did the warnings filter right?
It seems to work in CI at least.

@nicoddemus
Copy link
Member

Awesome!

@nicoddemus
Copy link
Member

Strange, I would expect the warnings to show only once, not for every call...

@@ -0,0 +1 @@
Deprecate ``_Result.excinfo`` in favor of ``_Result.get_result()``.
Copy link
Member

Choose a reason for hiding this comment

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

Missing a D here 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wait what?

@nicoddemus
Copy link
Member

Just checking the problematic code in pytest.

@hookimpl(hookwrapper=True)
def pytest_pyfunc_call(pyfuncitem):
    check_xfail_no_run(pyfuncitem)
    outcome = yield
    passed = outcome.excinfo is None
    if passed:
        check_strict_xfail(pyfuncitem)

becomes:

@hookimpl(hookwrapper=True)
def pytest_pyfunc_call(pyfuncitem):
    check_xfail_no_run(pyfuncitem)
    outcome = yield
    try:
        outcome.get_result()
        passed = True
    except Exception:
        passed = False
    if passed:
        check_strict_xfail(pyfuncitem)

TBH doesn't look like an improvement to me. Or am I missing something?

(To be clear, totally in favor about the deprecation of .result)

@goodboy
Copy link
Contributor Author

goodboy commented Jul 26, 2018

@nicoddemus I also think it's a little uglier but @RonnyPfannschmidt seemed convinced in #86.

@nicoddemus
Copy link
Member

I completely see the point of deprecating .result; it is too easy to forget to check for excinfo first to check for an exception, so definitely the user should always use .get_result() to get a result.

However for excinfo I'm not so convinced, because there's really no downside of the user checking for it or not. What do you think @RonnyPfannschmidt?

@goodboy
Copy link
Contributor Author

goodboy commented Jul 26, 2018

@nicoddemus btw we can also chat now on the new gitter channel!

@goodboy
Copy link
Contributor Author

goodboy commented Jul 29, 2018

@RonnyPfannschmidt still waiting on your input for this one.

@RonnyPfannschmidt
Copy link
Member

@nicoddemus the question does become if we should expose the actual exception, from my pov, the concrete values of exception/result should be hidden away,

the following questions come up to me

  1. does a single use really warrant exposing the data as is?
  2. are there other uses that may fit an api that exposes an abstract success/failure? concept?

@nicoddemus
Copy link
Member

does a single use really warrant exposing the data as is?

You mean a single use in pytest, or in a more general manner, like a single use case (verify if any exception has occurred)?

@RonnyPfannschmidt
Copy link
Member

@nicoddemus in that case single use of the value in pytest - i believe its important to consider point 2 in relation

@nicoddemus
Copy link
Member

A quick search shows that the only use case is indeed if a plugin is interested only if an exception has occurred or not.

TBH if we were discussing about including the API for excinfo I would agree we should look at a few more use cases first, but given we are talking about deprecating and then removing, I would like to see the use cases where keeping it is harmful (which is clearly the case of .result). It is just that so far, the few uses where checking if an exception has occurred will have to be rewritten, without a clear gain AFAICT.

@RonnyPfannschmidt
Copy link
Member

i find that reasoning acceptable, on principle i'd still prefer if we had a success/failure indicator instead of exposing the exception

@nicoddemus
Copy link
Member

That would work for pytest, but I did see some code in that search I posted before that were checking for a specific type of exception.

Also, we need to realize that we can always deprecate .excinfo later if we find a compelling use case to remove it.

@RonnyPfannschmidt
Copy link
Member

@nicoddemus do you have a link, at least on github most of the results are accidentally committed tox virtualenvs

@RonnyPfannschmidt
Copy link
Member

@nicoddemus all examples you linked use get_result and use pytest callinfo

@nicoddemus
Copy link
Member

Oh you are right. Anyway, the code in those links will still need to be updated eventually... well I will leave up to you then, I don't have any strong arguments anymore. 👍

@RonnyPfannschmidt
Copy link
Member

however it should be noted that all uses of the code would tremendously benefit from a failure indication

@RonnyPfannschmidt
Copy link
Member

based on the information we collected i believe its only fair to keep the api,
but eventually replace it with a python3 api since exceptions can carry tracebacks there

we should also consider introducing a failure indication as an orthogonal matter

@nicoddemus
Copy link
Member

nicoddemus commented Jul 30, 2018

we should also consider introducing a failure indication as an orthogonal matter

You have a suggestion? I think two read-only properties, passed and failed, might do the trick.

@RonnyPfannschmidt
Copy link
Member

failed/passed dont quite match - its not a test - ill sleep over it

@nicoddemus
Copy link
Member

Sounds good! 👍

@goodboy
Copy link
Contributor Author

goodboy commented Aug 3, 2018

Closing according to the consensus that we keep .excinfo until a better failure indication API is proposed to replace it.

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.

3 participants