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