rename recorder functionality, unify interfaces
--HG-- branch : trunk
This commit is contained in:
@@ -175,7 +175,7 @@ class TestCollectPluginHooks:
|
||||
assert "hello" in wascalled
|
||||
assert "world" in wascalled
|
||||
# make sure the directories do not get double-appended
|
||||
colreports = sorter.getreports("collectreport")
|
||||
colreports = sorter.getreports("pytest_collectreport")
|
||||
names = [rep.colitem.name for rep in colreports]
|
||||
assert names.count("hello") == 1
|
||||
|
||||
@@ -214,8 +214,8 @@ class TestCustomConftests:
|
||||
""")
|
||||
testdir.mkdir("hello")
|
||||
sorter = testdir.inline_run(testdir.tmpdir)
|
||||
names = [rep.colitem.name for rep in sorter.getreports("collectreport")]
|
||||
names = [rep.colitem.name for rep in sorter.getreports("pytest_collectreport")]
|
||||
assert 'hello' not in names
|
||||
evrec = testdir.inline_run(testdir.tmpdir, "--XX")
|
||||
names = [rep.colitem.name for rep in evrec.getreports("collectreport")]
|
||||
reprec = testdir.inline_run(testdir.tmpdir, "--XX")
|
||||
names = [rep.colitem.name for rep in reprec.getreports("pytest_collectreport")]
|
||||
assert 'hello' in names
|
||||
|
||||
@@ -74,7 +74,7 @@ class TestKeywordSelection:
|
||||
passed, skipped, failed = sorter.listoutcomes()
|
||||
assert len(failed) == 1
|
||||
assert failed[0].colitem.name == name
|
||||
assert len(sorter.getcalls('deselected')) == 1
|
||||
assert len(sorter.getcalls('pytest_deselected')) == 1
|
||||
|
||||
for keyword in ['test_one', 'est_on']:
|
||||
#yield check, keyword, 'test_one'
|
||||
|
||||
@@ -74,7 +74,7 @@ class TestBootstrapping:
|
||||
mod.pytest_plugins = "pytest_a"
|
||||
aplugin = testdir.makepyfile(pytest_a="#")
|
||||
pluginmanager = PluginManager()
|
||||
sorter = testdir.geteventrecorder(pluginmanager)
|
||||
sorter = testdir.getreportrecorder(pluginmanager)
|
||||
#syspath.prepend(aplugin.dirpath())
|
||||
py.std.sys.path.insert(0, str(aplugin.dirpath()))
|
||||
pluginmanager.consider_module(mod)
|
||||
@@ -83,7 +83,7 @@ class TestBootstrapping:
|
||||
|
||||
# check that it is not registered twice
|
||||
pluginmanager.consider_module(mod)
|
||||
l = sorter.getcalls("plugin_registered")
|
||||
l = sorter.getcalls("pytest_plugin_registered")
|
||||
assert len(l) == 1
|
||||
|
||||
def test_consider_conftest_deprecated(self, testdir):
|
||||
@@ -113,6 +113,19 @@ class TestBootstrapping:
|
||||
pp.unregister(a2)
|
||||
assert not pp.isregistered(a2)
|
||||
|
||||
def test_register_imported_modules(self):
|
||||
pp = PluginManager()
|
||||
mod = py.std.new.module("x.y.pytest_hello")
|
||||
pp.register(mod)
|
||||
assert pp.isregistered(mod)
|
||||
assert pp.getplugins() == [mod]
|
||||
py.test.raises(AssertionError, "pp.register(mod)")
|
||||
mod2 = py.std.new.module("pytest_hello")
|
||||
#pp.register(mod2) # double registry
|
||||
py.test.raises(AssertionError, "pp.register(mod)")
|
||||
#assert not pp.isregistered(mod2)
|
||||
assert pp.getplugins() == [mod] # does not actually modify plugins
|
||||
|
||||
def test_canonical_importname(self):
|
||||
for name in 'xyz', 'pytest_xyz', 'pytest_Xyz', 'Xyz':
|
||||
impname = canonical_importname(name)
|
||||
|
||||
@@ -19,7 +19,7 @@ class TestSetupStateFunctional:
|
||||
def test_func():
|
||||
pass
|
||||
""")
|
||||
evrec = testdir.geteventrecorder(item.config)
|
||||
reprec = testdir.getreportrecorder(item.config)
|
||||
setup = SetupState()
|
||||
res = setup.do_setup(item)
|
||||
assert res
|
||||
@@ -32,11 +32,11 @@ class TestSetupStateFunctional:
|
||||
def test_func():
|
||||
pass
|
||||
""")
|
||||
evrec = testdir.geteventrecorder(item.config)
|
||||
reprec = testdir.getreportrecorder(item.config)
|
||||
setup = SetupState()
|
||||
res = setup.do_setup(item)
|
||||
assert not res
|
||||
rep = evrec.popcall(pytest_itemsetupreport).rep
|
||||
rep = reprec.popcall(pytest_itemsetupreport).rep
|
||||
assert rep.failed
|
||||
assert not rep.skipped
|
||||
assert rep.excrepr
|
||||
@@ -51,14 +51,14 @@ class TestSetupStateFunctional:
|
||||
print "13"
|
||||
raise ValueError(25)
|
||||
""")
|
||||
evrec = testdir.geteventrecorder(item.config)
|
||||
reprec = testdir.getreportrecorder(item.config)
|
||||
setup = SetupState()
|
||||
res = setup.do_setup(item)
|
||||
assert res
|
||||
rep = evrec.popcall(pytest_itemsetupreport).rep
|
||||
rep = reprec.popcall(pytest_itemsetupreport).rep
|
||||
assert rep.passed
|
||||
setup.do_teardown(item)
|
||||
rep = evrec.popcall(pytest_itemsetupreport).rep
|
||||
rep = reprec.popcall(pytest_itemsetupreport).rep
|
||||
assert rep.item == item
|
||||
assert rep.failed
|
||||
assert not rep.passed
|
||||
@@ -73,10 +73,10 @@ class TestSetupStateFunctional:
|
||||
def test_func():
|
||||
pass
|
||||
""")
|
||||
evrec = testdir.geteventrecorder(item.config)
|
||||
reprec = testdir.getreportrecorder(item.config)
|
||||
setup = SetupState()
|
||||
setup.do_setup(item)
|
||||
rep = evrec.popcall(pytest_itemsetupreport).rep
|
||||
rep = reprec.popcall(pytest_itemsetupreport).rep
|
||||
assert not rep.failed
|
||||
assert rep.skipped
|
||||
assert rep.excrepr
|
||||
@@ -84,18 +84,18 @@ class TestSetupStateFunctional:
|
||||
|
||||
def test_runtest_ok(self, testdir):
|
||||
item = testdir.getitem("def test_func(): pass")
|
||||
evrec = testdir.geteventrecorder(item.config)
|
||||
reprec = testdir.getreportrecorder(item.config)
|
||||
setup = SetupState()
|
||||
setup.do_fixture_and_runtest(item)
|
||||
rep = evrec.popcall(pytest_itemtestreport).rep
|
||||
rep = reprec.popcall(pytest_itemtestreport).rep
|
||||
assert rep.passed
|
||||
|
||||
def test_runtest_fails(self, testdir):
|
||||
item = testdir.getitem("def test_func(): assert 0")
|
||||
evrec = testdir.geteventrecorder(item.config)
|
||||
reprec = testdir.getreportrecorder(item.config)
|
||||
setup = SetupState()
|
||||
setup.do_fixture_and_runtest(item)
|
||||
event = evrec.popcall(pytest_item_runtest_finished)
|
||||
event = reprec.popcall(pytest_item_runtest_finished)
|
||||
assert event.excinfo
|
||||
|
||||
|
||||
|
||||
@@ -25,9 +25,9 @@ class SessionTests:
|
||||
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("itemstart")
|
||||
itemstarted = sorter.getcalls("pytest_itemstart")
|
||||
assert len(itemstarted) == 4
|
||||
colstarted = sorter.getcalls("collectstart")
|
||||
colstarted = sorter.getcalls("pytest_collectstart")
|
||||
assert len(colstarted) == 1
|
||||
col = colstarted[0].collector
|
||||
assert isinstance(col, py.test.collect.Module)
|
||||
@@ -130,7 +130,7 @@ class SessionTests:
|
||||
def test_one(): pass
|
||||
""")
|
||||
sorter = testdir.inline_run(testdir.tmpdir)
|
||||
reports = sorter.getreports("collectreport")
|
||||
reports = sorter.getreports("pytest_collectreport")
|
||||
assert len(reports) == 1
|
||||
assert reports[0].skipped
|
||||
|
||||
@@ -201,9 +201,9 @@ class TestNewSession(SessionTests):
|
||||
|
||||
itemstarted = sorter.getcalls("pytest_itemstart")
|
||||
assert len(itemstarted) == 3
|
||||
assert not sorter.getreports("itemtestreport")
|
||||
assert not sorter.getreports("pytest_itemtestreport")
|
||||
started = sorter.getcalls("pytest_collectstart")
|
||||
finished = sorter.getreports("collectreport")
|
||||
finished = sorter.getreports("pytest_collectreport")
|
||||
assert len(started) == len(finished)
|
||||
assert len(started) == 8
|
||||
colfail = [x for x in finished if x.failed]
|
||||
@@ -215,7 +215,7 @@ class TestNewSession(SessionTests):
|
||||
testdir.makepyfile(__init__="")
|
||||
testdir.makepyfile(test_one="xxxx", test_two="yyyy")
|
||||
sorter = testdir.inline_run("-x", testdir.tmpdir)
|
||||
finished = sorter.getreports("collectreport")
|
||||
finished = sorter.getreports("pytest_collectreport")
|
||||
colfail = [x for x in finished if x.failed]
|
||||
assert len(colfail) == 1
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ def test_func_generator_setup(testdir):
|
||||
yield check
|
||||
assert x == [1]
|
||||
""")
|
||||
rep = sorter.matchreport("test_one", names="itemtestreport")
|
||||
rep = sorter.matchreport("test_one", names="pytest_itemtestreport")
|
||||
assert rep.passed
|
||||
|
||||
def test_method_setup_uses_fresh_instances(testdir):
|
||||
|
||||
Reference in New Issue
Block a user