2009-09-06 22:59:39 +08:00
|
|
|
|
|
|
|
class TestPasting:
|
|
|
|
def pytest_funcarg__pastebinlist(self, request):
|
2010-07-27 03:15:15 +08:00
|
|
|
mp = request.getfuncargvalue("monkeypatch")
|
2009-09-06 22:59:39 +08:00
|
|
|
pastebinlist = []
|
|
|
|
class MockProxy:
|
|
|
|
def newPaste(self, language, code):
|
|
|
|
pastebinlist.append((language, code))
|
2009-10-17 18:56:59 +08:00
|
|
|
plugin = request.config.pluginmanager.getplugin('pastebin')
|
2010-07-27 03:15:15 +08:00
|
|
|
mp.setattr(plugin, 'getproxy', MockProxy)
|
|
|
|
return pastebinlist
|
2009-09-06 22:59:39 +08:00
|
|
|
|
|
|
|
def test_failed(self, testdir, pastebinlist):
|
|
|
|
testpath = testdir.makepyfile("""
|
2010-11-18 05:12:16 +08:00
|
|
|
import pytest
|
2009-09-06 22:59:39 +08:00
|
|
|
def test_pass():
|
|
|
|
pass
|
|
|
|
def test_fail():
|
|
|
|
assert 0
|
|
|
|
def test_skip():
|
2010-11-18 05:12:16 +08:00
|
|
|
pytest.skip("")
|
2009-09-06 22:59:39 +08:00
|
|
|
""")
|
|
|
|
reprec = testdir.inline_run(testpath, "--paste=failed")
|
|
|
|
assert len(pastebinlist) == 1
|
|
|
|
assert pastebinlist[0][0] == "python"
|
|
|
|
s = pastebinlist[0][1]
|
|
|
|
assert s.find("def test_fail") != -1
|
|
|
|
assert reprec.countoutcomes() == [1,1,1]
|
|
|
|
|
|
|
|
def test_all(self, testdir, pastebinlist):
|
|
|
|
testpath = testdir.makepyfile("""
|
2010-11-18 05:12:16 +08:00
|
|
|
import pytest
|
2009-09-06 22:59:39 +08:00
|
|
|
def test_pass():
|
|
|
|
pass
|
|
|
|
def test_fail():
|
|
|
|
assert 0
|
|
|
|
def test_skip():
|
2010-11-18 05:12:16 +08:00
|
|
|
pytest.skip("")
|
2009-09-06 22:59:39 +08:00
|
|
|
""")
|
|
|
|
reprec = testdir.inline_run(testpath, "--pastebin=all")
|
|
|
|
assert reprec.countoutcomes() == [1,1,1]
|
|
|
|
assert len(pastebinlist) == 1
|
|
|
|
assert pastebinlist[0][0] == "python"
|
|
|
|
s = pastebinlist[0][1]
|
|
|
|
for x in 'test_fail test_skip skipped'.split():
|
|
|
|
assert s.find(x), (s, x)
|
2010-07-27 03:15:15 +08:00
|
|
|
|
2011-11-15 00:51:12 +08:00
|
|
|
|
|
|
|
class TestRPCClient:
|
|
|
|
def pytest_funcarg__pastebin(self, request):
|
|
|
|
return request.config.pluginmanager.getplugin('pastebin')
|
|
|
|
|
|
|
|
def test_getproxy(self, pastebin):
|
|
|
|
proxy = pastebin.getproxy()
|
|
|
|
assert proxy is not None
|
|
|
|
assert proxy.__class__.__module__.startswith('xmlrpc')
|
|
|
|
|
2013-10-12 21:39:22 +08:00
|
|
|
|