[pytest-dev] Fwd: Continuing on failures
Brian Okken
variedthoughts at gmail.com
Fri Mar 27 12:32:53 EDT 2020
I'd even be more than ok with a context manager approach and even using
asserts within the context manager.
As long as you can have more than one assert fail within the context.
-Brian
On Fri, Mar 27, 2020 at 9:30 AM Brian Okken <variedthoughts at gmail.com>
wrote:
> Victor,
>
> This would be brilliant. There is a fairly large need for a soft assert
> feature.
> pytest-check would not be needed if it existed.
>
> I personally would not want it to be an overriding of assert, but perhaps
> a different function that is used almost identically to assert, including
> failing the test, but just not stopping execution.
> This is also the reason why many people resort to subtest.
>
> -Brian Okken
>
> On Fri, Mar 27, 2020 at 9:19 AM Victor Maryama <victor.maryama at gmail.com>
> wrote:
>
>> Oh sure, I see now what you mean.
>>
>> Back then when I was thinking about this subject it seemed to me that
>> soft assertions could be something implemented in pytest core itself using
>> the assertion rewriting module (which in turn would put the assertion calls
>> around the context manager), along the lines of what Bruno mentioned.
>> Except that I probably would not go for a generic hook, but just the soft
>> assertion feature itself.
>>
>>
>> On Fri, Mar 27, 2020, 5:09 PM Maximilian Roos <m at maximilianroos.com>
>> wrote:
>>
>>> Hi Victor,
>>>
>>> > What about pytest-assume as a context manager around the assert line?
>>>
>>> Yes, this could work with either a context manager or a function like
>>> pytest-check uses.
>>> But it couples the plugin to the tests; it's no longer possible to run
>>> the plugin on normal tests with a plain `assert`, which is some of the
>>> brilliant philosophy of pytest.
>>>
>>> Without such a hook, I think the function or context manager is the best
>>> path forward, and is a reasonable way to build a better prototype before
>>> adding hooks deep in pytest internals.
>>>
>>> Thank you!
>>> Max
>>>
>>> On Fri, 27 Mar 2020 at 09:26, Victor Maryama <victor.maryama at gmail.com>
>>> wrote:
>>>
>>>> What about pytest-assume as a context manager around the assert line?
>>>> That way you get the soft assertions feature and pytest still rewrites
>>>> the assertions.
>>>>
>>>> On Fri, Mar 27, 2020, 12:47 PM Bruno Oliveira <nicoddemus at gmail.com>
>>>> wrote:
>>>>
>>>>> Hi Maximilian,
>>>>>
>>>>> On Thu, Mar 26, 2020 at 7:29 PM Maximilian Roos <m at maximilianroos.com>
>>>>> wrote:
>>>>>
>>>>>>
>>>>>> To prefix: as a long time user and evangelizer of pytest, a big thank
>>>>>> you for the superb tool.
>>>>>>
>>>>>
>>>>> Thanks for the kind words, we appreciate it.
>>>>>
>>>>>
>>>>>> As per that README, it only works on the first failure, because the
>>>>>> test doesn't continue execution beyond that. *Is there any way of
>>>>>> allowing execution to continue, without ripping up the internals of pytest?*
>>>>>> My prior is "no", since the assertion rewrite still retains an assertion,
>>>>>> and there's no hook for changing that.
>>>>>>
>>>>>
>>>>> Not at the moment I'm afraid.
>>>>>
>>>>> I think it should be possible to implement a hook that transforms the
>>>>> AST, which our rewriter would then call. I think, with this hook in place,
>>>>> you would be able to rewrite assert statements into a function call of your
>>>>> plugin, which would then be free to do whatever it wanted. If you are
>>>>> interested, I suggest writing up a proposal in the issue tracker so it can
>>>>> be discussed.
>>>>>
>>>>> Cheers,
>>>>> Bruno
>>>>>
>>>>>
>>>>>> Ref: a similar question I asked @okken
>>>>>> https://github.com/okken/pytest-check/issues/32
>>>>>>
>>>>>> Thank you,
>>>>>> Max
>>>>>> _______________________________________________
>>>>>> pytest-dev mailing list
>>>>>> pytest-dev at python.org
>>>>>> https://mail.python.org/mailman/listinfo/pytest-dev
>>>>>>
>>>>> _______________________________________________
>>>>> pytest-dev mailing list
>>>>> pytest-dev at python.org
>>>>> https://mail.python.org/mailman/listinfo/pytest-dev
>>>>>
>>>>> _______________________________________________
>> pytest-dev mailing list
>> pytest-dev at python.org
>> https://mail.python.org/mailman/listinfo/pytest-dev
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pytest-dev/attachments/20200327/9aa64a3e/attachment-0001.html>
More information about the pytest-dev
mailing list