Every line of 'pytest assert exception' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
538 def test_pytest_fail(): 539 try: 540 pytest.fail("hello") 541 except pytest.fail.Exception: 542 excinfo = _pytest._code.ExceptionInfo() 543 s = excinfo.exconly(tryshort=True) 544 assert s.startswith("Failed")
31 def pytest_raises(exc_iter): 32 def decorator(f): 33 def wrapper(*args, **kwargs): 34 with pytest.raises(exc_iter): 35 f(*args, **kwargs) 36 return wrapper 37 return decorator
869 def assertExpectedRaises(self, exc_type, callable, *args, **kwargs): 870 subname = None 871 if 'subname' in kwargs: 872 subname = kwargs['subname'] 873 del kwargs['subname'] 874 try: 875 callable(*args, **kwargs) 876 except exc_type as e: 877 self.assertExpected(str(e), subname) 878 return 879 # Don't put this in the try block; the AssertionError will catch it 880 self.fail(msg="Did not raise when expected to")
155 def test_raises(self): 156 s = "qwe" # NOQA 157 raises(TypeError, "int(s)")