rename sorter to reprec (report-recorder)
--HG-- branch : trunk
This commit is contained in:
parent
d4a28b1b2d
commit
ec34e9423e
|
@ -108,10 +108,10 @@ class TestNodeManager:
|
|||
config = py.test.config._reparse([source, '--debug'])
|
||||
assert config.option.debug
|
||||
nodemanager = NodeManager(config, specs)
|
||||
sorter = testdir.getreportrecorder(config).hookrecorder
|
||||
reprec = testdir.getreportrecorder(config).hookrecorder
|
||||
nodemanager.setup_nodes(putevent=[].append)
|
||||
for spec in nodemanager.gwmanager.specs:
|
||||
l = sorter.getcalls("pytest_trace")
|
||||
l = reprec.getcalls("pytest_trace")
|
||||
assert l
|
||||
nodemanager.teardown_nodes()
|
||||
|
||||
|
@ -120,8 +120,8 @@ class TestNodeManager:
|
|||
def test_one():
|
||||
pass
|
||||
""")
|
||||
sorter = testdir.inline_run("-d", "--rsyncdir=%s" % testdir.tmpdir,
|
||||
"--tx=%s" % specssh, testdir.tmpdir)
|
||||
ev = sorter.getfirstnamed(pytest_itemtestreport)
|
||||
reprec = testdir.inline_run("-d", "--rsyncdir=%s" % testdir.tmpdir,
|
||||
"--tx %s" % specssh, testdir.tmpdir)
|
||||
ev = reprec.getfirstnamed("pytest_itemtestreport")
|
||||
assert ev.passed
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ def test_functional_default(testdir, _pytest):
|
|||
assert _pytest.comregistry != reg
|
||||
|
||||
def test_functional(testdir, linecomp):
|
||||
sorter = testdir.inline_runsource("""
|
||||
reprec = testdir.inline_runsource("""
|
||||
import py
|
||||
pytest_plugins="_pytest"
|
||||
def test_func(_pytest):
|
||||
|
@ -135,4 +135,4 @@ def test_functional(testdir, linecomp):
|
|||
res = rec.hook.xyz(arg=41)
|
||||
assert res == [42]
|
||||
""")
|
||||
sorter.assertoutcome(passed=1)
|
||||
reprec.assertoutcome(passed=1)
|
||||
|
|
|
@ -89,7 +89,7 @@ class TestDoctests:
|
|||
""")
|
||||
for x in (testdir.tmpdir, checkfile):
|
||||
#print "checking that %s returns custom items" % (x,)
|
||||
items, sorter = testdir.inline_genitems(x)
|
||||
items, reprec = testdir.inline_genitems(x)
|
||||
assert len(items) == 1
|
||||
assert isinstance(items[0], DoctestTextfile)
|
||||
|
||||
|
@ -106,8 +106,8 @@ class TestDoctests:
|
|||
>>> x == 1
|
||||
False
|
||||
""")
|
||||
sorter = testdir.inline_run(p)
|
||||
sorter.assertoutcome(failed=1)
|
||||
reprec = testdir.inline_run(p)
|
||||
reprec.assertoutcome(failed=1)
|
||||
|
||||
def test_doctest_unexpected_exception(self, testdir):
|
||||
from py.__.test.outcome import Failed
|
||||
|
@ -118,8 +118,8 @@ class TestDoctests:
|
|||
>>> x
|
||||
2
|
||||
""")
|
||||
sorter = testdir.inline_run(p)
|
||||
call = sorter.getcall("pytest_itemtestreport")
|
||||
reprec = testdir.inline_run(p)
|
||||
call = reprec.getcall("pytest_itemtestreport")
|
||||
assert call.rep.failed
|
||||
assert call.rep.longrepr
|
||||
# XXX
|
||||
|
@ -137,8 +137,8 @@ class TestDoctests:
|
|||
|
||||
'''
|
||||
""")
|
||||
sorter = testdir.inline_run(p, "--doctest-modules")
|
||||
sorter.assertoutcome(failed=1)
|
||||
reprec = testdir.inline_run(p, "--doctest-modules")
|
||||
reprec.assertoutcome(failed=1)
|
||||
|
||||
def test_txtfile_failing(self, testdir):
|
||||
testdir.plugins.append("doctest")
|
||||
|
|
|
@ -86,11 +86,11 @@ def test_setenv():
|
|||
assert 'XYZ123' not in os.environ
|
||||
|
||||
def test_monkeypatch_plugin(testdir):
|
||||
sorter = testdir.inline_runsource("""
|
||||
reprec = testdir.inline_runsource("""
|
||||
pytest_plugins = 'pytest_monkeypatch',
|
||||
def test_method(monkeypatch):
|
||||
assert monkeypatch.__class__.__name__ == "MonkeyPatch"
|
||||
""")
|
||||
res = sorter.countoutcomes()
|
||||
res = reprec.countoutcomes()
|
||||
assert tuple(res) == (1, 0, 0), res
|
||||
|
||||
|
|
|
@ -161,10 +161,10 @@ class TmpTestdir:
|
|||
config = self.parseconfig(*args)
|
||||
config.pluginmanager.do_configure(config)
|
||||
session = config.initsession()
|
||||
sorter = self.getreportrecorder(config)
|
||||
reprec = self.getreportrecorder(config)
|
||||
session.main()
|
||||
config.pluginmanager.do_unconfigure(config)
|
||||
return sorter
|
||||
return reprec
|
||||
|
||||
def config_preparse(self):
|
||||
config = self.Config()
|
||||
|
|
|
@ -73,7 +73,7 @@ def test_WarningRecorder():
|
|||
assert showwarning == py.std.warnings.showwarning
|
||||
|
||||
def test_recwarn_functional(testdir):
|
||||
sorter = testdir.inline_runsource("""
|
||||
reprec = testdir.inline_runsource("""
|
||||
pytest_plugins = 'pytest_recwarn',
|
||||
import warnings
|
||||
oldwarn = warnings.showwarning
|
||||
|
@ -85,6 +85,6 @@ def test_recwarn_functional(testdir):
|
|||
def test_finalized():
|
||||
assert warnings.showwarning == oldwarn
|
||||
""")
|
||||
res = sorter.countoutcomes()
|
||||
res = reprec.countoutcomes()
|
||||
assert tuple(res) == (2, 0, 0), res
|
||||
|
||||
|
|
|
@ -409,8 +409,8 @@ class TestDoctest:
|
|||
.. >>> raise ValueError
|
||||
>>> None
|
||||
""")
|
||||
sorter = testdir.inline_run(xtxt)
|
||||
passed, skipped, failed = sorter.countoutcomes()
|
||||
reprec = testdir.inline_run(xtxt)
|
||||
passed, skipped, failed = reprec.countoutcomes()
|
||||
assert failed == 1
|
||||
|
||||
def test_doctest_basic(self, testdir):
|
||||
|
@ -432,23 +432,23 @@ class TestDoctest:
|
|||
|
||||
end
|
||||
""")
|
||||
sorter = testdir.inline_run(xtxt)
|
||||
passed, skipped, failed = sorter.countoutcomes()
|
||||
reprec = testdir.inline_run(xtxt)
|
||||
passed, skipped, failed = reprec.countoutcomes()
|
||||
assert failed == 0
|
||||
assert passed + skipped == 2
|
||||
|
||||
def test_doctest_eol(self, testdir):
|
||||
ytxt = testdir.maketxtfile(y=".. >>> 1 + 1\r\n 2\r\n\r\n")
|
||||
sorter = testdir.inline_run(ytxt)
|
||||
passed, skipped, failed = sorter.countoutcomes()
|
||||
reprec = testdir.inline_run(ytxt)
|
||||
passed, skipped, failed = reprec.countoutcomes()
|
||||
assert failed == 0
|
||||
assert passed + skipped == 2
|
||||
|
||||
def test_doctest_indentation(self, testdir):
|
||||
footxt = testdir.maketxtfile(foo=
|
||||
'..\n >>> print "foo\\n bar"\n foo\n bar\n')
|
||||
sorter = testdir.inline_run(footxt)
|
||||
passed, skipped, failed = sorter.countoutcomes()
|
||||
reprec = testdir.inline_run(footxt)
|
||||
passed, skipped, failed = reprec.countoutcomes()
|
||||
assert failed == 0
|
||||
assert skipped + passed == 2
|
||||
|
||||
|
@ -458,8 +458,8 @@ class TestDoctest:
|
|||
|
||||
.. _`blah`: javascript:some_function()
|
||||
""")
|
||||
sorter = testdir.inline_run(xtxt)
|
||||
passed, skipped, failed = sorter.countoutcomes()
|
||||
reprec = testdir.inline_run(xtxt)
|
||||
passed, skipped, failed = reprec.countoutcomes()
|
||||
assert failed == 0
|
||||
assert skipped + passed == 3
|
||||
|
||||
|
@ -479,9 +479,9 @@ class TestDoctest:
|
|||
False
|
||||
|
||||
""")
|
||||
sorter = testdir.inline_run(xtxt)
|
||||
reprec = testdir.inline_run(xtxt)
|
||||
assert len(l) == 1
|
||||
passed, skipped, failed = sorter.countoutcomes()
|
||||
passed, skipped, failed = reprec.countoutcomes()
|
||||
assert passed >= 1
|
||||
assert not failed
|
||||
assert skipped <= 1
|
||||
|
|
|
@ -208,32 +208,32 @@ class TestRunnerPlugin:
|
|||
item = testdir.getitem("""def test_func(): pass""")
|
||||
plugin = RunnerPlugin()
|
||||
plugin.pytest_configure(item.config)
|
||||
sorter = testdir.getreportrecorder(item)
|
||||
reprec = testdir.getreportrecorder(item)
|
||||
plugin.pytest_item_setup_and_runtest(item)
|
||||
rep = sorter.getcall("pytest_itemtestreport").rep
|
||||
rep = reprec.getcall("pytest_itemtestreport").rep
|
||||
assert rep.passed
|
||||
|
||||
class TestSetupEvents:
|
||||
disabled = True
|
||||
|
||||
def test_setup_runtest_ok(self, testdir):
|
||||
sorter = testdir.inline_runsource("""
|
||||
reprec = testdir.inline_runsource("""
|
||||
def setup_module(mod):
|
||||
pass
|
||||
def test_func():
|
||||
pass
|
||||
""")
|
||||
assert not sorter.getcalls(pytest_itemsetupreport)
|
||||
assert not reprec.getcalls(pytest_itemsetupreport)
|
||||
|
||||
def test_setup_fails(self, testdir):
|
||||
sorter = testdir.inline_runsource("""
|
||||
reprec = testdir.inline_runsource("""
|
||||
def setup_module(mod):
|
||||
print "world"
|
||||
raise ValueError(42)
|
||||
def test_func():
|
||||
pass
|
||||
""")
|
||||
rep = sorter.popcall(pytest_itemsetupreport).rep
|
||||
rep = reprec.popcall(pytest_itemsetupreport).rep
|
||||
assert rep.failed
|
||||
assert not rep.skipped
|
||||
assert rep.excrepr
|
||||
|
@ -241,7 +241,7 @@ class TestSetupEvents:
|
|||
assert rep.outerr[0].find("world") != -1
|
||||
|
||||
def test_teardown_fails(self, testdir):
|
||||
sorter = testdir.inline_runsource("""
|
||||
reprec = testdir.inline_runsource("""
|
||||
def test_func():
|
||||
pass
|
||||
def teardown_function(func):
|
||||
|
@ -256,14 +256,14 @@ class TestSetupEvents:
|
|||
assert "25" in str(rep.excrepr)
|
||||
|
||||
def test_setup_skips(self, testdir):
|
||||
sorter = testdir.inline_runsource("""
|
||||
reprec = testdir.inline_runsource("""
|
||||
import py
|
||||
def setup_module(mod):
|
||||
py.test.skip("17")
|
||||
def test_func():
|
||||
pass
|
||||
""")
|
||||
rep = sorter.popcall(pytest_itemsetupreport)
|
||||
rep = reprec.popcall(pytest_itemsetupreport)
|
||||
assert not rep.failed
|
||||
assert rep.skipped
|
||||
assert rep.excrepr
|
||||
|
|
|
@ -78,9 +78,9 @@ def test_simple_unittest(testdir):
|
|||
def test_failing(self):
|
||||
self.assertEquals('foo', 'bar')
|
||||
""")
|
||||
sorter = testdir.inline_run(testpath)
|
||||
assert sorter.matchreport("testpassing").passed
|
||||
assert sorter.matchreport("test_failing").failed
|
||||
reprec = testdir.inline_run(testpath)
|
||||
assert reprec.matchreport("testpassing").passed
|
||||
assert reprec.matchreport("test_failing").failed
|
||||
|
||||
def test_setup(testdir):
|
||||
testpath = testdir.makepyfile(test_two="""
|
||||
|
@ -92,8 +92,8 @@ def test_setup(testdir):
|
|||
def test_setUp(self):
|
||||
self.assertEquals(1, self.foo)
|
||||
""")
|
||||
sorter = testdir.inline_run(testpath)
|
||||
rep = sorter.matchreport("test_setUp")
|
||||
reprec = testdir.inline_run(testpath)
|
||||
rep = reprec.matchreport("test_setUp")
|
||||
assert rep.passed
|
||||
|
||||
def test_teardown(testdir):
|
||||
|
@ -110,8 +110,8 @@ def test_teardown(testdir):
|
|||
def test_check(self):
|
||||
self.assertEquals(MyTestCase.l, [None])
|
||||
""")
|
||||
sorter = testdir.inline_run(testpath)
|
||||
passed, skipped, failed = sorter.countoutcomes()
|
||||
reprec = testdir.inline_run(testpath)
|
||||
passed, skipped, failed = reprec.countoutcomes()
|
||||
print "COUNTS", passed, skipped, failed
|
||||
assert failed == 0, failed
|
||||
assert passed == 2
|
||||
|
|
|
@ -171,11 +171,11 @@ class TestCollectPluginHooks:
|
|||
testdir.plugins.append(Plugin())
|
||||
testdir.mkdir("hello")
|
||||
testdir.mkdir("world")
|
||||
sorter = testdir.inline_run()
|
||||
reprec = testdir.inline_run()
|
||||
assert "hello" in wascalled
|
||||
assert "world" in wascalled
|
||||
# make sure the directories do not get double-appended
|
||||
colreports = sorter.getreports("pytest_collectreport")
|
||||
colreports = reprec.getreports("pytest_collectreport")
|
||||
names = [rep.colitem.name for rep in colreports]
|
||||
assert names.count("hello") == 1
|
||||
|
||||
|
@ -213,8 +213,8 @@ class TestCustomConftests:
|
|||
return parent.config.getvalue("XX")
|
||||
""")
|
||||
testdir.mkdir("hello")
|
||||
sorter = testdir.inline_run(testdir.tmpdir)
|
||||
names = [rep.colitem.name for rep in sorter.getreports("pytest_collectreport")]
|
||||
reprec = testdir.inline_run(testdir.tmpdir)
|
||||
names = [rep.colitem.name for rep in reprec.getreports("pytest_collectreport")]
|
||||
assert 'hello' not in names
|
||||
reprec = testdir.inline_run(testdir.tmpdir, "--XX")
|
||||
names = [rep.colitem.name for rep in reprec.getreports("pytest_collectreport")]
|
||||
|
|
|
@ -303,8 +303,8 @@ class TestConfig_gettopdir:
|
|||
|
||||
def test_options_on_small_file_do_not_blow_up(testdir):
|
||||
def runfiletest(opts):
|
||||
sorter = testdir.inline_run(*opts)
|
||||
passed, skipped, failed = sorter.countoutcomes()
|
||||
reprec = testdir.inline_run(*opts)
|
||||
passed, skipped, failed = reprec.countoutcomes()
|
||||
assert failed == 2
|
||||
assert skipped == passed == 0
|
||||
path = testdir.makepyfile("""
|
||||
|
|
|
@ -10,7 +10,7 @@ class Test_genitems:
|
|||
pass
|
||||
""")
|
||||
p.copy(p.dirpath(p.purebasename + "2" + ".py"))
|
||||
items, sorter = testdir.inline_genitems(p.dirpath())
|
||||
items, reprec = testdir.inline_genitems(p.dirpath())
|
||||
assert len(items) == 4
|
||||
for numi, i in enumerate(items):
|
||||
for numj, j in enumerate(items):
|
||||
|
@ -27,8 +27,8 @@ class Test_genitems:
|
|||
def test_subdir_conftest_error(self, testdir):
|
||||
tmp = testdir.tmpdir
|
||||
tmp.ensure("sub", "conftest.py").write("raise SyntaxError\n")
|
||||
items, sorter = testdir.inline_genitems(tmp)
|
||||
collectionfailures = sorter.getfailedcollections()
|
||||
items, reprec = testdir.inline_genitems(tmp)
|
||||
collectionfailures = reprec.getfailedcollections()
|
||||
assert len(collectionfailures) == 1
|
||||
ev = collectionfailures[0]
|
||||
assert ev.longrepr.reprcrash.message.startswith("SyntaxError")
|
||||
|
@ -45,7 +45,7 @@ class Test_genitems:
|
|||
class TestY(TestX):
|
||||
pass
|
||||
''')
|
||||
items, sorter = testdir.inline_genitems(p)
|
||||
items, reprec = testdir.inline_genitems(p)
|
||||
assert len(items) == 3
|
||||
assert items[0].name == 'testone'
|
||||
assert items[1].name == 'testmethod_one'
|
||||
|
@ -70,11 +70,11 @@ class TestKeywordSelection:
|
|||
assert 42 == 43
|
||||
""")
|
||||
def check(keyword, name):
|
||||
sorter = testdir.inline_run("-s", "-k", keyword, file_test)
|
||||
passed, skipped, failed = sorter.listoutcomes()
|
||||
reprec = testdir.inline_run("-s", "-k", keyword, file_test)
|
||||
passed, skipped, failed = reprec.listoutcomes()
|
||||
assert len(failed) == 1
|
||||
assert failed[0].colitem.name == name
|
||||
assert len(sorter.getcalls('pytest_deselected')) == 1
|
||||
assert len(reprec.getcalls('pytest_deselected')) == 1
|
||||
|
||||
for keyword in ['test_one', 'est_on']:
|
||||
#yield check, keyword, 'test_one'
|
||||
|
@ -97,12 +97,12 @@ class TestKeywordSelection:
|
|||
""")
|
||||
for keyword in ('xxx', 'xxx test_2', 'TestClass', 'xxx -test_1',
|
||||
'TestClass test_2', 'xxx TestClass test_2',):
|
||||
sorter = testdir.inline_run(p.dirpath(), '-s', '-k', keyword)
|
||||
reprec = testdir.inline_run(p.dirpath(), '-s', '-k', keyword)
|
||||
print "keyword", repr(keyword)
|
||||
passed, skipped, failed = sorter.listoutcomes()
|
||||
passed, skipped, failed = reprec.listoutcomes()
|
||||
assert len(passed) == 1
|
||||
assert passed[0].colitem.name == "test_2"
|
||||
dlist = sorter.getcalls("pytest_deselected")
|
||||
dlist = reprec.getcalls("pytest_deselected")
|
||||
assert len(dlist) == 1
|
||||
assert dlist[0].items[0].name == 'test_1'
|
||||
|
||||
|
@ -112,11 +112,11 @@ class TestKeywordSelection:
|
|||
def test_two(): assert 1
|
||||
def test_three(): assert 1
|
||||
""")
|
||||
sorter = testdir.inline_run("-k", "test_two:", threepass)
|
||||
passed, skipped, failed = sorter.listoutcomes()
|
||||
reprec = testdir.inline_run("-k", "test_two:", threepass)
|
||||
passed, skipped, failed = reprec.listoutcomes()
|
||||
assert len(passed) == 2
|
||||
assert not failed
|
||||
dlist = sorter.getcalls("pytest_deselected")
|
||||
dlist = reprec.getcalls("pytest_deselected")
|
||||
assert len(dlist) == 1
|
||||
item = dlist[0].items[0]
|
||||
assert item.name == "test_one"
|
||||
|
|
|
@ -74,16 +74,16 @@ class TestBootstrapping:
|
|||
mod.pytest_plugins = "pytest_a"
|
||||
aplugin = testdir.makepyfile(pytest_a="#")
|
||||
pluginmanager = PluginManager()
|
||||
sorter = testdir.getreportrecorder(pluginmanager)
|
||||
reprec = testdir.getreportrecorder(pluginmanager)
|
||||
#syspath.prepend(aplugin.dirpath())
|
||||
py.std.sys.path.insert(0, str(aplugin.dirpath()))
|
||||
pluginmanager.consider_module(mod)
|
||||
call = sorter.getcall(pluginmanager.hook.pytest_plugin_registered.name)
|
||||
call = reprec.getcall(pluginmanager.hook.pytest_plugin_registered.name)
|
||||
assert call.plugin.__name__ == "pytest_a"
|
||||
|
||||
# check that it is not registered twice
|
||||
pluginmanager.consider_module(mod)
|
||||
l = sorter.getcalls("pytest_plugin_registered")
|
||||
l = reprec.getcalls("pytest_plugin_registered")
|
||||
assert len(l) == 1
|
||||
|
||||
def test_consider_conftest_deprecated(self, testdir):
|
||||
|
|
|
@ -179,8 +179,8 @@ class TestGenerator:
|
|||
yield list_append, i
|
||||
yield assert_order_of_execution
|
||||
""")
|
||||
sorter = testdir.inline_run(o)
|
||||
passed, skipped, failed = sorter.countoutcomes()
|
||||
reprec = testdir.inline_run(o)
|
||||
passed, skipped, failed = reprec.countoutcomes()
|
||||
assert passed == 7
|
||||
assert not skipped and not failed
|
||||
|
||||
|
@ -209,8 +209,8 @@ class TestGenerator:
|
|||
yield list_append_2
|
||||
yield assert_order_of_execution
|
||||
""")
|
||||
sorter = testdir.inline_run(o)
|
||||
passed, skipped, failed = sorter.countoutcomes()
|
||||
reprec = testdir.inline_run(o)
|
||||
passed, skipped, failed = reprec.countoutcomes()
|
||||
assert passed == 4
|
||||
assert not skipped and not failed
|
||||
|
||||
|
|
|
@ -17,17 +17,17 @@ class SessionTests:
|
|||
def test_two(someargs):
|
||||
pass
|
||||
""")
|
||||
sorter = testdir.inline_run(tfile)
|
||||
passed, skipped, failed = sorter.listoutcomes()
|
||||
reprec = testdir.inline_run(tfile)
|
||||
passed, skipped, failed = reprec.listoutcomes()
|
||||
assert len(skipped) == 0
|
||||
assert len(passed) == 1
|
||||
assert len(failed) == 3
|
||||
assert failed[0].colitem.name == "test_one_one"
|
||||
assert failed[1].colitem.name == "test_other"
|
||||
assert failed[2].colitem.name == "test_two"
|
||||
itemstarted = sorter.getcalls("pytest_itemstart")
|
||||
itemstarted = reprec.getcalls("pytest_itemstart")
|
||||
assert len(itemstarted) == 4
|
||||
colstarted = sorter.getcalls("pytest_collectstart")
|
||||
colstarted = reprec.getcalls("pytest_collectstart")
|
||||
assert len(colstarted) == 1
|
||||
col = colstarted[0].collector
|
||||
assert isinstance(col, py.test.collect.Module)
|
||||
|
@ -41,19 +41,19 @@ class SessionTests:
|
|||
import does_not_work
|
||||
a = 1
|
||||
""")
|
||||
sorter = testdir.inline_run(tfile)
|
||||
l = sorter.getfailedcollections()
|
||||
reprec = testdir.inline_run(tfile)
|
||||
l = reprec.getfailedcollections()
|
||||
assert len(l) == 1
|
||||
out = l[0].longrepr.reprcrash.message
|
||||
assert out.find('does_not_work') != -1
|
||||
|
||||
def test_raises_output(self, testdir):
|
||||
sorter = testdir.inline_runsource("""
|
||||
reprec = testdir.inline_runsource("""
|
||||
import py
|
||||
def test_raises_doesnt():
|
||||
py.test.raises(ValueError, int, "3")
|
||||
""")
|
||||
passed, skipped, failed = sorter.listoutcomes()
|
||||
passed, skipped, failed = reprec.listoutcomes()
|
||||
assert len(failed) == 1
|
||||
out = failed[0].longrepr.reprcrash.message
|
||||
if not out.find("DID NOT RAISE") != -1:
|
||||
|
@ -61,28 +61,28 @@ class SessionTests:
|
|||
py.test.fail("incorrect raises() output")
|
||||
|
||||
def test_generator_yields_None(self, testdir):
|
||||
sorter = testdir.inline_runsource("""
|
||||
reprec = testdir.inline_runsource("""
|
||||
def test_1():
|
||||
yield None
|
||||
""")
|
||||
failures = sorter.getfailedcollections()
|
||||
failures = reprec.getfailedcollections()
|
||||
out = failures[0].longrepr.reprcrash.message
|
||||
i = out.find('TypeError')
|
||||
assert i != -1
|
||||
|
||||
def test_syntax_error_module(self, testdir):
|
||||
sorter = testdir.inline_runsource("this is really not python")
|
||||
l = sorter.getfailedcollections()
|
||||
reprec = testdir.inline_runsource("this is really not python")
|
||||
l = reprec.getfailedcollections()
|
||||
assert len(l) == 1
|
||||
out = l[0].longrepr.reprcrash.message
|
||||
assert out.find(str('not python')) != -1
|
||||
|
||||
def test_exit_first_problem(self, testdir):
|
||||
sorter = testdir.inline_runsource("""
|
||||
reprec = testdir.inline_runsource("""
|
||||
def test_one(): assert 0
|
||||
def test_two(): assert 0
|
||||
""", '--exitfirst')
|
||||
passed, skipped, failed = sorter.countoutcomes()
|
||||
passed, skipped, failed = reprec.countoutcomes()
|
||||
assert failed == 1
|
||||
assert passed == skipped == 0
|
||||
|
||||
|
@ -111,8 +111,8 @@ class SessionTests:
|
|||
t = BrokenRepr2()
|
||||
assert t.foo == 1
|
||||
""")
|
||||
sorter = testdir.inline_run(p)
|
||||
passed, skipped, failed = sorter.listoutcomes()
|
||||
reprec = testdir.inline_run(p)
|
||||
passed, skipped, failed = reprec.listoutcomes()
|
||||
assert len(failed) == 2
|
||||
out = failed[0].longrepr.reprcrash.message
|
||||
assert out.find("""[Exception("Ha Ha fooled you, I'm a broken repr().") raised in repr()]""") != -1 #'
|
||||
|
@ -129,8 +129,8 @@ class SessionTests:
|
|||
""", test_file="""
|
||||
def test_one(): pass
|
||||
""")
|
||||
sorter = testdir.inline_run(testdir.tmpdir)
|
||||
reports = sorter.getreports("pytest_collectreport")
|
||||
reprec = testdir.inline_run(testdir.tmpdir)
|
||||
reports = reprec.getreports("pytest_collectreport")
|
||||
assert len(reports) == 1
|
||||
assert reports[0].skipped
|
||||
|
||||
|
@ -145,15 +145,15 @@ class TestNewSession(SessionTests):
|
|||
def mypdb(*args):
|
||||
l.append(args)
|
||||
monkeypatch.setattr(py.__.test.custompdb, 'post_mortem', mypdb)
|
||||
sorter = testdir.inline_run('--pdb', tfile)
|
||||
rep = sorter.matchreport("test_usepdb")
|
||||
reprec = testdir.inline_run('--pdb', tfile)
|
||||
rep = reprec.matchreport("test_usepdb")
|
||||
assert rep.failed
|
||||
assert len(l) == 1
|
||||
tb = py.code.Traceback(l[0][0])
|
||||
assert tb[-1].name == "test_usepdb"
|
||||
|
||||
def test_order_of_execution(self, testdir):
|
||||
sorter = testdir.inline_runsource("""
|
||||
reprec = testdir.inline_runsource("""
|
||||
l = []
|
||||
def test_1():
|
||||
l.append(1)
|
||||
|
@ -172,7 +172,7 @@ class TestNewSession(SessionTests):
|
|||
def test_4(self):
|
||||
assert self.reslist == [1,2,1,2,3]
|
||||
""")
|
||||
passed, skipped, failed = sorter.countoutcomes()
|
||||
passed, skipped, failed = reprec.countoutcomes()
|
||||
assert failed == skipped == 0
|
||||
assert passed == 7
|
||||
# also test listnames() here ...
|
||||
|
@ -197,13 +197,13 @@ class TestNewSession(SessionTests):
|
|||
test_three="xxxdsadsadsadsa",
|
||||
__init__=""
|
||||
)
|
||||
sorter = testdir.inline_run('--collectonly', p.dirpath())
|
||||
reprec = testdir.inline_run('--collectonly', p.dirpath())
|
||||
|
||||
itemstarted = sorter.getcalls("pytest_itemstart")
|
||||
itemstarted = reprec.getcalls("pytest_itemstart")
|
||||
assert len(itemstarted) == 3
|
||||
assert not sorter.getreports("pytest_itemtestreport")
|
||||
started = sorter.getcalls("pytest_collectstart")
|
||||
finished = sorter.getreports("pytest_collectreport")
|
||||
assert not reprec.getreports("pytest_itemtestreport")
|
||||
started = reprec.getcalls("pytest_collectstart")
|
||||
finished = reprec.getreports("pytest_collectreport")
|
||||
assert len(started) == len(finished)
|
||||
assert len(started) == 8
|
||||
colfail = [x for x in finished if x.failed]
|
||||
|
@ -214,8 +214,8 @@ class TestNewSession(SessionTests):
|
|||
def test_minus_x_import_error(self, testdir):
|
||||
testdir.makepyfile(__init__="")
|
||||
testdir.makepyfile(test_one="xxxx", test_two="yyyy")
|
||||
sorter = testdir.inline_run("-x", testdir.tmpdir)
|
||||
finished = sorter.getreports("pytest_collectreport")
|
||||
reprec = testdir.inline_run("-x", testdir.tmpdir)
|
||||
finished = reprec.getreports("pytest_collectreport")
|
||||
colfail = [x for x in finished if x.failed]
|
||||
assert len(colfail) == 1
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# module, class, and instance level
|
||||
|
||||
def test_module_and_function_setup(testdir):
|
||||
sorter = testdir.inline_runsource("""
|
||||
reprec = testdir.inline_runsource("""
|
||||
modlevel = []
|
||||
def setup_module(module):
|
||||
assert not modlevel
|
||||
|
@ -27,13 +27,13 @@ def test_module_and_function_setup(testdir):
|
|||
assert modlevel[0] == 42
|
||||
assert not hasattr(test_modlevel, 'answer')
|
||||
""")
|
||||
rep = sorter.matchreport("test_modlevel")
|
||||
rep = reprec.matchreport("test_modlevel")
|
||||
assert rep.passed
|
||||
rep = sorter.matchreport("test_module")
|
||||
rep = reprec.matchreport("test_module")
|
||||
assert rep.passed
|
||||
|
||||
def test_class_setup(testdir):
|
||||
sorter = testdir.inline_runsource("""
|
||||
reprec = testdir.inline_runsource("""
|
||||
class TestSimpleClassSetup:
|
||||
clslevel = []
|
||||
def setup_class(cls):
|
||||
|
@ -53,10 +53,10 @@ def test_class_setup(testdir):
|
|||
assert not TestSimpleClassSetup.clslevel
|
||||
assert not TestInheritedClassSetupStillWorks.clslevel
|
||||
""")
|
||||
sorter.assertoutcome(passed=1+2+1)
|
||||
reprec.assertoutcome(passed=1+2+1)
|
||||
|
||||
def test_method_setup(testdir):
|
||||
sorter = testdir.inline_runsource("""
|
||||
reprec = testdir.inline_runsource("""
|
||||
class TestSetupMethod:
|
||||
def setup_method(self, meth):
|
||||
self.methsetup = meth
|
||||
|
@ -69,10 +69,10 @@ def test_method_setup(testdir):
|
|||
def test_other(self):
|
||||
assert self.methsetup == self.test_other
|
||||
""")
|
||||
sorter.assertoutcome(passed=2)
|
||||
reprec.assertoutcome(passed=2)
|
||||
|
||||
def test_method_generator_setup(testdir):
|
||||
sorter = testdir.inline_runsource("""
|
||||
reprec = testdir.inline_runsource("""
|
||||
class TestSetupTeardownOnInstance:
|
||||
def setup_class(cls):
|
||||
cls.classsetup = True
|
||||
|
@ -91,10 +91,10 @@ def test_method_generator_setup(testdir):
|
|||
assert self.methsetup == self.test_generate
|
||||
assert value == 5
|
||||
""")
|
||||
sorter.assertoutcome(passed=1, failed=1)
|
||||
reprec.assertoutcome(passed=1, failed=1)
|
||||
|
||||
def test_func_generator_setup(testdir):
|
||||
sorter = testdir.inline_runsource("""
|
||||
reprec = testdir.inline_runsource("""
|
||||
import sys
|
||||
|
||||
def setup_module(mod):
|
||||
|
@ -118,11 +118,11 @@ def test_func_generator_setup(testdir):
|
|||
yield check
|
||||
assert x == [1]
|
||||
""")
|
||||
rep = sorter.matchreport("test_one", names="pytest_itemtestreport")
|
||||
rep = reprec.matchreport("test_one", names="pytest_itemtestreport")
|
||||
assert rep.passed
|
||||
|
||||
def test_method_setup_uses_fresh_instances(testdir):
|
||||
sorter = testdir.inline_runsource("""
|
||||
reprec = testdir.inline_runsource("""
|
||||
class TestSelfState1:
|
||||
def __init__(self):
|
||||
self.hello = 42
|
||||
|
@ -137,5 +137,5 @@ def test_method_setup_uses_fresh_instances(testdir):
|
|||
def test_world(self):
|
||||
assert not hasattr(self, 'world')
|
||||
""")
|
||||
sorter.assertoutcome(passed=4, failed=0)
|
||||
reprec.assertoutcome(passed=4, failed=0)
|
||||
|
||||
|
|
Loading…
Reference in New Issue