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

Bruno Oliveira nicoddemus at gmail.com
Thu Mar 30 12:12:30 EDT 2017


Hi all,

We are about to land on the features branch an implementation of the
proposal outlined by Florian Bruhin (
https://github.com/pytest-dev/pytest/issues/1830) where we introduce a
small helper to facilitate writing parametrized tests that sometimes raise
an error for an input parameter and sometimes don’t:

@pytest.mark.parametrize('inp, expectation', [
    (-1, pytest.raises(ValueError)),
    (3.5, pytest.raises(TypeError)),
    (5, pytest.does_not_raise),
    (10, pytest.does_not_raise),
])def test_bar(inp, expectation):
    with expectation:
        validate_positive_integer(inp)

The pytest.does_not_raise helper actually does nothing, is meant solely to
help writing this type of parametrized test.

The PR is at https://github.com/pytest-dev/pytest/pull/2339 and is ready
for merging, but this email is about *how to name it* since we had some
debate about it.

We have this proposals so far:

   - pytest.does_not_raise;
   - pytest.not_raises;
   - pytest.wont_raise;

So we would like to ask for opinions here because nailing down the name is
important.

*Another question* is if someone sees a problem in making it a singleton
like in the example above, or if we should force users instantiate it each
time: pytest.does_not_raise().

Cheers,
​
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pytest-dev/attachments/20170330/ae15d901/attachment.html>


More information about the pytest-dev mailing list