Download How do I properly assert that an exception gets raised in pytest? book pdf free download link or read online here in PDF. Read online How do I properly assert that an exception gets raised in pytest? book pdf free download link book now. All books are in clear copy here, and all files are secure so don't worry about it. This site is like a library, you could find million book here by using search box in the header.
pytest.raises(Exception) is what you need. Code. import pytest def test_passes(): with pytest.raises(Exception) as e_info: x = 1 / 0 def test_passes_without_info(): with pytest.raises(Exception): x = 1 / 0 def test_fails(): with pytest.raises(Exception) as e_info: x = 1 / 1 def test_fails_without_info(): with pytest.raises(Exception): x = 1 / 1 # Don't do this.
Read : How do I properly assert that an exception gets raised in pytest? pdf book online Select one of servers for direct link: |
---|