<s> import pytest <EOL> class TestRaises : <EOL> def test_raises ( self ) : <EOL> source = "<STR_LIT>" <EOL> excinfo = pytest . raises ( ValueError , source ) <EOL> code = excinfo . traceback [ - <NUM_LIT:1> ] . frame . code <EOL> s = str ( code . fullsource ) <EOL> assert s == source <EOL> def test_raises_exec ( self ) : <EOL> pytest . raises ( ValueError , "<STR_LIT>" ) <EOL> def test_raises_syntax_error ( self ) : <EOL> pytest . raises ( SyntaxError , "<STR_LIT>" ) <EOL> def test_raises_function ( self ) : <EOL> pytest . raises ( ValueError , int , '<STR_LIT:hello>' ) <EOL> def test_raises_callable_no_exception ( self ) : <EOL> class A : <EOL> def __call__ ( self ) : <EOL> pass <EOL> try : <EOL> pytest . raises ( ValueError , A ( ) ) <EOL> except pytest . raises . Exception : <EOL> pass <EOL> def test_raises_flip_builtin_AssertionError ( self ) : <EOL> from _pytest . assertion . util import BuiltinAssertionError <EOL> pytest . raises ( AssertionError , """<STR_LIT>""" ) <EOL> def test_raises_as_contextmanager ( self , testdir ) : <EOL> testdir . makepyfile ( """<STR_LIT>""" ) <EOL> result = testdir . runpytest ( ) <EOL> result . stdout . fnmatch_lines ( [ <EOL> '<STR_LIT>' , <EOL> ] ) <EOL> def test_noclass ( self ) : <EOL> with pytest . raises ( TypeError ) : <EOL> pytest . raises ( '<STR_LIT>' , lambda : None ) <EOL> def test_tuple ( self ) : <EOL> with pytest . raises ( ( KeyError , ValueError ) ) : <EOL> raise KeyError ( '<STR_LIT>' ) <EOL> def test_no_raise_message ( self ) : <EOL> try : <EOL> pytest . raises ( ValueError , int , '<STR_LIT:0>' ) <EOL> except pytest . raises . Exception as e : <EOL> assert e . msg == "<STR_LIT>" . format ( repr ( ValueError ) ) </s>
