You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following construct used pervasively in tests/test_config.py:
with pytest.raises(subprocess.CalledProcessError) as e:
cmd('...')
assert 'error string' in str(e)
but this doesn't work for two reasons:
The assert statement must be outside the context manager (i.e. dedented one level) for it to execute at all if the exception is raised
The error string is very often not part of the exception object, so one needs to check the captured stderr instead
Something like this works instead:
with pytest.raises(subprocess.CalledProcessError) as exc_info:
cmd('...', stderr=subprocess.STDOUT)
err_msg = exc_info.value.output.decode("utf-8")
assert 'str' in err_msg
The text was updated successfully, but these errors were encountered:
Thanks @carlescufi ! Could you submit "quick" fixes for the "easy" ones? Leave the more complex ones for later / someone with more spare time. As far as test coverage is concerned, quantity matters!
The following construct used pervasively in
tests/test_config.py
:but this doesn't work for two reasons:
assert
statement must be outside the context manager (i.e. dedented one level) for it to execute at all if the exception is raisedSomething like this works instead:
The text was updated successfully, but these errors were encountered: