[pytest-dev] [3.1 feature] "assert not raise exception" helper: opinions about the name

Ronny Pfannschmidt opensource at ronnypfannschmidt.de
Thu Mar 30 17:08:06 EDT 2017


I do because we make something a "magical god function" again, more of the rant tommorow.

Gn8, Ronny

Am 30. März 2017 23:03:45 MESZ schrieb Bruno Oliveira <nicoddemus at gmail.com>:
>On Thu, Mar 30, 2017 at 4:32 PM holger krekel <holger at merlinux.eu>
>wrote:
>
>> It's a bit odd to introduce a new helper just for this particular
>case.
>> After skimming https://github.com/pytest-dev/pytest/issues/1830
>> i'd prefer the mentioned pytest.raises(None) solution which lets
>through
>> all exceptions
>> of the dependent code block.  Adding an example to the pytest docs
>and
>> extending
>> the pytest.raises help string and implementation would be enough IMO.
>> By contrast, adding a new helper feels like unneccessary clutter of
>> the pytest.* namespace. The above would then be:
>>
>>  @pytest.mark.parametrize('inp, expectation', [
>>      (-1, ValueError),
>>      (3.5, TypeError),
>>      (5, None),
>>      (10, None)])
>>  def test_bar(inp, expectation):
>>      with pytest.raises(expectation):
>>          validate_positive_integer(inp)
>>
>> where the parametrization is shorter and if one does not know
>> what pytest.raises(None) means one could find it easily in the
>> doc string or the pytest docs.
>>
>
>I agree. Does anybody else still prefers the original proposal?
>
>Cheers,
>Bruno.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pytest-dev/attachments/20170330/c05e023e/attachment-0001.html>


More information about the pytest-dev mailing list