<s> import py <EOL> from py . __ . test . outcome import Skipped <EOL> class TestModule : <EOL> def test_module_file_not_found ( self , testdir ) : <EOL> tmpdir = testdir . tmpdir <EOL> fn = tmpdir . join ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> col = py . test . collect . Module ( fn ) <EOL> col . config = testdir . parseconfig ( tmpdir ) <EOL> py . test . raises ( py . error . ENOENT , col . collect ) <EOL> def test_failing_import ( self , testdir ) : <EOL> modcol = testdir . getmodulecol ( "<STR_LIT>" ) <EOL> py . test . raises ( ImportError , modcol . collect ) <EOL> py . test . raises ( ImportError , modcol . collect ) <EOL> py . test . raises ( ImportError , modcol . run ) <EOL> def test_syntax_error_in_module ( self , testdir ) : <EOL> modcol = testdir . getmodulecol ( "<STR_LIT>" ) <EOL> py . test . raises ( SyntaxError , modcol . collect ) <EOL> py . test . raises ( SyntaxError , modcol . collect ) <EOL> py . test . raises ( SyntaxError , modcol . run ) <EOL> def test_module_assertion_setup ( self , testdir , monkeypatch ) : <EOL> modcol = testdir . getmodulecol ( "<STR_LIT>" ) <EOL> from py . __ . magic import assertion <EOL> l = [ ] <EOL> monkeypatch . setattr ( assertion , "<STR_LIT>" , lambda : l . append ( None ) ) <EOL> modcol . setup ( ) <EOL> x = l . pop ( ) <EOL> assert x is None <EOL> monkeypatch . setattr ( assertion , "<STR_LIT>" , lambda : l . append ( None ) ) <EOL> modcol . teardown ( ) <EOL> x = l . pop ( ) <EOL> assert x is None <EOL> def test_module_considers_pluginmanager_at_import ( self , testdir ) : <EOL> modcol = testdir . getmodulecol ( "<STR_LIT>" ) <EOL> py . test . raises ( ImportError , "<STR_LIT>" ) <EOL> class TestClass : <EOL> def test_class_with_init_not_collected ( self , testdir ) : <EOL> modcol = testdir . getmodulecol ( """<STR_LIT>""" ) <EOL> l = modcol . collect ( ) <EOL> assert len ( l ) == <NUM_LIT:0> <EOL> class TestDisabled : <EOL> def test_disabled_module ( self , testdir ) : <EOL> modcol = testdir . getmodulecol ( """<STR_LIT>""" ) <EOL> l = modcol . collect ( ) <EOL> assert len ( l ) == <NUM_LIT:1> <EOL> py . test . raises ( Skipped , "<STR_LIT>" ) <EOL> def test_disabled_class ( self , testdir ) : <EOL> modcol = testdir . getmodulecol ( """<STR_LIT>""" ) <EOL> l = modcol . collect ( ) <EOL> assert len ( l ) == <NUM_LIT:1> <EOL> modcol = l [ <NUM_LIT:0> ] <EOL> assert isinstance ( modcol , py . test . collect . Class ) <EOL> l = modcol . collect ( ) <EOL> assert len ( l ) == <NUM_LIT:1> <EOL> py . test . raises ( Skipped , "<STR_LIT>" ) <EOL> def test_disabled_class_functional ( self , testdir ) : <EOL> reprec = testdir . inline_runsource ( """<STR_LIT>""" ) <EOL> reprec . assertoutcome ( skipped = <NUM_LIT:2> ) <EOL> class TestGenerator : <EOL> def test_generative_functions ( self , testdir ) : <EOL> modcol = testdir . getmodulecol ( """<STR_LIT>""" ) <EOL> colitems = modcol . collect ( ) <EOL> assert len ( colitems ) == <NUM_LIT:1> <EOL> gencol = colitems [ <NUM_LIT:0> ] <EOL> assert isinstance ( gencol , py . test . collect . Generator ) <EOL> gencolitems = gencol . collect ( ) <EOL> assert len ( gencolitems ) == <NUM_LIT:2> <EOL> assert isinstance ( gencolitems [ <NUM_LIT:0> ] , py . test . collect . Function ) <EOL> assert isinstance ( gencolitems [ <NUM_LIT:1> ] , py . test . collect . Function ) <EOL> assert gencolitems [ <NUM_LIT:0> ] . name == '<STR_LIT>' <EOL> assert gencolitems [ <NUM_LIT:0> ] . obj . func_name == '<STR_LIT>' <EOL> def test_generative_methods ( self , testdir ) : <EOL> modcol = testdir . getmodulecol ( """<STR_LIT>""" ) <EOL> gencol = modcol . collect ( ) [ <NUM_LIT:0> ] . collect ( ) [ <NUM_LIT:0> ] . collect ( ) [ <NUM_LIT:0> ] <EOL> assert isinstance ( gencol , py . test . collect . Generator ) <EOL> gencolitems = gencol . collect ( ) <EOL> assert len ( gencolitems ) == <NUM_LIT:2> <EOL> assert isinstance ( gencolitems [ <NUM_LIT:0> ] , py . test . collect . Function ) <EOL> assert isinstance ( gencolitems [ <NUM_LIT:1> ] , py . test . collect . Function ) <EOL> assert gencolitems [ <NUM_LIT:0> ] . name == '<STR_LIT>' <EOL> assert gencolitems [ <NUM_LIT:0> ] . obj . func_name == '<STR_LIT>' <EOL> def test_generative_functions_with_explicit_names ( self , testdir ) : <EOL> modcol = testdir . getmodulecol ( """<STR_LIT>""" ) <EOL> colitems = modcol . collect ( ) <EOL> assert len ( colitems ) == <NUM_LIT:1> <EOL> gencol = colitems [ <NUM_LIT:0> ] <EOL> assert isinstance ( gencol , py . test . collect . Generator ) <EOL> gencolitems = gencol . collect ( ) <EOL> assert len ( gencolitems ) == <NUM_LIT:2> <EOL> assert isinstance ( gencolitems [ <NUM_LIT:0> ] , py . test . collect . Function ) <EOL> assert isinstance ( gencolitems [ <NUM_LIT:1> ] , py . test . collect . Function ) <EOL> assert gencolitems [ <NUM_LIT:0> ] . name == "<STR_LIT>" <EOL> assert gencolitems [ <NUM_LIT:0> ] . obj . func_name == '<STR_LIT>' <EOL> assert gencolitems [ <NUM_LIT:1> ] . name == "<STR_LIT>" <EOL> assert gencolitems [ <NUM_LIT:1> ] . obj . func_name == '<STR_LIT>' <EOL> def test_generative_functions_unique_explicit_names ( self , testdir ) : <EOL> modcol = testdir . getmodulecol ( """<STR_LIT>""" ) <EOL> colitems = modcol . collect ( ) <EOL> assert len ( colitems ) == <NUM_LIT:1> <EOL> gencol = colitems [ <NUM_LIT:0> ] <EOL> assert isinstance ( gencol , py . test . collect . Generator ) <EOL> py . test . raises ( ValueError , "<STR_LIT>" ) <EOL> def test_generative_methods_with_explicit_names ( self , testdir ) : <EOL> modcol = testdir . getmodulecol ( """<STR_LIT>""" ) <EOL> gencol = modcol . collect ( ) [ <NUM_LIT:0> ] . collect ( ) [ <NUM_LIT:0> ] . collect ( ) [ <NUM_LIT:0> ] <EOL> assert isinstance ( gencol , py . test . collect . Generator ) <EOL> gencolitems = gencol . collect ( ) <EOL> assert len ( gencolitems ) == <NUM_LIT:2> <EOL> assert isinstance ( gencolitems [ <NUM_LIT:0> ] , py . test . collect . Function ) <EOL> assert isinstance ( gencolitems [ <NUM_LIT:1> ] , py . test . collect . Function ) <EOL> assert gencolitems [ <NUM_LIT:0> ] . name == "<STR_LIT>" <EOL> assert gencolitems [ <NUM_LIT:0> ] . obj . func_name == '<STR_LIT>' <EOL> assert gencolitems [ <NUM_LIT:1> ] . name == "<STR_LIT>" <EOL> assert gencolitems [ <NUM_LIT:1> ] . obj . func_name == '<STR_LIT>' <EOL> def test_order_of_execution_generator_same_codeline ( self , testdir , tmpdir ) : <EOL> o = testdir . makepyfile ( """<STR_LIT>""" ) <EOL> reprec = testdir . inline_run ( o ) <EOL> passed , skipped , failed = reprec . countoutcomes ( ) <EOL> assert passed == <NUM_LIT:7> <EOL> assert not skipped and not failed <EOL> def test_order_of_execution_generator_different_codeline ( self , testdir ) : <EOL> o = testdir . makepyfile ( """<STR_LIT>""" ) <EOL> reprec = testdir . inline_run ( o ) <EOL> passed , skipped , failed = reprec . countoutcomes ( ) <EOL> assert passed == <NUM_LIT:4> <EOL> assert not skipped and not failed <EOL> class TestFunction : <EOL> def test_getmodulecollector ( self , testdir ) : <EOL> item = testdir . getitem ( "<STR_LIT>" ) <EOL> modcol = item . getparent ( py . test . collect . Module ) <EOL> assert isinstance ( modcol , py . test . collect . Module ) <EOL> assert hasattr ( modcol . obj , '<STR_LIT>' ) <EOL> def test_function_equality ( self , tmpdir ) : <EOL> config = py . test . config . _reparse ( [ tmpdir ] ) <EOL> f1 = py . test . collect . Function ( name = "<STR_LIT:name>" , <EOL> args = ( <NUM_LIT:1> , ) , callobj = isinstance ) <EOL> f2 = py . test . collect . Function ( name = "<STR_LIT:name>" , <EOL> args = ( <NUM_LIT:1> , ) , callobj = callable ) <EOL> assert not f1 == f2 <EOL> assert f1 != f2 <EOL> f3 = py . test . collect . Function ( name = "<STR_LIT:name>" , <EOL> args = ( <NUM_LIT:1> , <NUM_LIT:2> ) , callobj = callable ) <EOL> assert not f3 == f2 <EOL> assert f3 != f2 <EOL> assert not f3 == f1 <EOL> assert f3 != f1 <EOL> f1_b = py . test . collect . Function ( name = "<STR_LIT:name>" , <EOL> args = ( <NUM_LIT:1> , ) , callobj = isinstance ) <EOL> assert f1 == f1_b <EOL> assert not f1 != f1_b <EOL> def test_function_equality_with_callspec ( self , tmpdir ) : <EOL> config = py . test . config . _reparse ( [ tmpdir ] ) <EOL> class callspec1 : <EOL> param = <NUM_LIT:1> <EOL> funcargs = { } <EOL> id = "<STR_LIT:hello>" <EOL> class callspec2 : <EOL> param = <NUM_LIT:1> <EOL> funcargs = { } <EOL> id = "<STR_LIT>" <EOL> f5 = py . test . collect . Function ( name = "<STR_LIT:name>" , <EOL> callspec = callspec1 , callobj = isinstance ) <EOL> f5b = py . test . collect . Function ( name = "<STR_LIT:name>" , <EOL> callspec = callspec2 , callobj = isinstance ) <EOL> assert f5 != f5b <EOL> assert not ( f5 == f5b ) <EOL> def test_pyfunc_call ( self , testdir ) : <EOL> item = testdir . getitem ( "<STR_LIT>" ) <EOL> config = item . config <EOL> class MyPlugin1 : <EOL> def pytest_pyfunc_call ( self , pyfuncitem ) : <EOL> raise ValueError <EOL> class MyPlugin2 : <EOL> def pytest_pyfunc_call ( self , pyfuncitem ) : <EOL> return True <EOL> config . pluginmanager . register ( MyPlugin1 ( ) ) <EOL> config . pluginmanager . register ( MyPlugin2 ( ) ) <EOL> config . hook . pytest_pyfunc_call ( pyfuncitem = item ) <EOL> class TestSorting : <EOL> def test_check_equality ( self , testdir ) : <EOL> modcol = testdir . getmodulecol ( """<STR_LIT>""" ) <EOL> fn1 = modcol . collect_by_name ( "<STR_LIT>" ) <EOL> assert isinstance ( fn1 , py . test . collect . Function ) <EOL> fn2 = modcol . collect_by_name ( "<STR_LIT>" ) <EOL> assert isinstance ( fn2 , py . test . collect . Function ) <EOL> assert fn1 == fn2 <EOL> assert fn1 != modcol <EOL> assert cmp ( fn1 , fn2 ) == <NUM_LIT:0> <EOL> assert hash ( fn1 ) == hash ( fn2 ) <EOL> fn3 = modcol . collect_by_name ( "<STR_LIT>" ) <EOL> assert isinstance ( fn3 , py . test . collect . Function ) <EOL> assert not ( fn1 == fn3 ) <EOL> assert fn1 != fn3 <EOL> for fn in fn1 , fn2 , fn3 : <EOL> assert fn != <NUM_LIT:3> <EOL> assert fn != modcol <EOL> assert fn != [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] <EOL> assert [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] != fn <EOL> assert modcol != fn <EOL> def test_allow_sane_sorting_for_decorators ( self , testdir ) : <EOL> modcol = testdir . getmodulecol ( """<STR_LIT>""" ) <EOL> colitems = modcol . collect ( ) <EOL> assert len ( colitems ) == <NUM_LIT:2> <EOL> assert [ item . name for item in colitems ] == [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> class TestConftestCustomization : <EOL> def test_extra_python_files_and_functions ( self , testdir ) : <EOL> testdir . makepyfile ( conftest = """<STR_LIT>""" ) <EOL> checkfile = testdir . makepyfile ( check_file = """<STR_LIT>""" ) <EOL> config = testdir . parseconfig ( ) <EOL> col = config . getfsnode ( checkfile . dirpath ( ) ) <EOL> colitems = col . collect ( ) <EOL> assert len ( colitems ) == <NUM_LIT:1> <EOL> assert isinstance ( colitems [ <NUM_LIT:0> ] , py . test . collect . Module ) <EOL> config = testdir . parseconfig ( checkfile ) <EOL> col = config . getfsnode ( checkfile ) <EOL> assert isinstance ( col , py . test . collect . Module ) <EOL> colitems = col . collect ( ) <EOL> assert len ( colitems ) == <NUM_LIT:2> <EOL> funccol = colitems [ <NUM_LIT:0> ] <EOL> assert isinstance ( funccol , py . test . collect . Function ) <EOL> assert funccol . name == "<STR_LIT>" <EOL> clscol = colitems [ <NUM_LIT:1> ] <EOL> assert isinstance ( clscol , py . test . collect . Class ) <EOL> colitems = clscol . collect ( ) [ <NUM_LIT:0> ] . collect ( ) <EOL> assert len ( colitems ) == <NUM_LIT:1> <EOL> assert colitems [ <NUM_LIT:0> ] . name == "<STR_LIT>" <EOL> class TestReportinfo : <EOL> def test_func_reportinfo ( self , testdir ) : <EOL> item = testdir . getitem ( "<STR_LIT>" ) <EOL> fspath , lineno , modpath = item . reportinfo ( ) <EOL> assert fspath == item . fspath <EOL> assert lineno == <NUM_LIT:0> <EOL> assert modpath == "<STR_LIT>" <EOL> def test_class_reportinfo ( self , testdir ) : <EOL> modcol = testdir . getmodulecol ( """<STR_LIT>""" ) <EOL> classcol = modcol . collect_by_name ( "<STR_LIT>" ) <EOL> fspath , lineno , msg = classcol . reportinfo ( ) <EOL> assert fspath == modcol . fspath <EOL> assert lineno == <NUM_LIT:1> <EOL> assert msg == "<STR_LIT>" <EOL> def test_generator_reportinfo ( self , testdir ) : <EOL> modcol = testdir . getmodulecol ( """<STR_LIT>""" ) <EOL> gencol = modcol . collect_by_name ( "<STR_LIT>" ) <EOL> fspath , lineno , modpath = gencol . reportinfo ( ) <EOL> assert fspath == modcol . fspath <EOL> assert lineno == <NUM_LIT:1> <EOL> assert modpath == "<STR_LIT>" <EOL> genitem = gencol . collect ( ) [ <NUM_LIT:0> ] <EOL> fspath , lineno , modpath = genitem . reportinfo ( ) <EOL> assert fspath == modcol . fspath <EOL> assert lineno == <NUM_LIT:2> <EOL> assert modpath == "<STR_LIT>" <EOL> """<STR_LIT>""" </s>
