* fixing lots of remaining 3k compatibility issues, mostly with py.test itself.
* removing very old import-tests that IIRC relate to a time when there was a custom import hook in use. * basically py.test internal tests pass now except py3/py2 distributed testing tests --HG-- branch : trunk
This commit is contained in:
@@ -67,8 +67,8 @@ per-test capturing. Here is an example test function:
|
||||
.. sourcecode:: python
|
||||
|
||||
def test_myoutput(capsys):
|
||||
print "hello"
|
||||
print >>sys.stderr, "world"
|
||||
print ("hello")
|
||||
sys.stderr.write("world\n")
|
||||
out, err = capsys.readouterr()
|
||||
assert out == "hello\\n"
|
||||
assert err == "world\\n"
|
||||
|
||||
@@ -48,7 +48,7 @@ def test_execnetplugin(testdir):
|
||||
sys._gw = py.execnet.PopenGateway()
|
||||
def test_world():
|
||||
assert hasattr(sys, '_gw')
|
||||
py.test.raises(KeyError, "sys._gw.exit()") # already closed
|
||||
assert sys._gw not in sys._gw._cleanup._activegateways
|
||||
|
||||
""", "-s", "--debug")
|
||||
reprec.assertoutcome(passed=2)
|
||||
|
||||
@@ -30,7 +30,7 @@ def pytest_configure(__multicall__, config):
|
||||
tw.sep("-")
|
||||
|
||||
options = [opt for opt in options if opt._long_opts]
|
||||
options.sort(lambda x, y: cmp(x._long_opts, y._long_opts))
|
||||
options.sort(key=lambda x: x._long_opts)
|
||||
for opt in options:
|
||||
if not opt._long_opts:
|
||||
continue
|
||||
|
||||
@@ -8,7 +8,7 @@ def pytest_addoption(parser):
|
||||
def pytest_configure(config):
|
||||
hooklog = config.getvalue("hooklog")
|
||||
if hooklog:
|
||||
config._hooklogfile = open(hooklog, 'w', 0)
|
||||
config._hooklogfile = open(hooklog, 'w')
|
||||
config._hooklog_oldperformcall = config.hook._performcall
|
||||
config.hook._performcall = (lambda name, multicall:
|
||||
logged_call(name=name, multicall=multicall, config=config))
|
||||
|
||||
@@ -37,7 +37,7 @@ def pytest_configure(__multicall__, config):
|
||||
import tempfile
|
||||
__multicall__.execute()
|
||||
if config.option.pastebin == "all":
|
||||
config._pastebinfile = tempfile.TemporaryFile()
|
||||
config._pastebinfile = tempfile.TemporaryFile('w+')
|
||||
tr = config.pluginmanager.impname2plugin['terminalreporter']
|
||||
oldwrite = tr._tw.write
|
||||
def tee_write(s, **kwargs):
|
||||
@@ -53,7 +53,7 @@ def pytest_unconfigure(config):
|
||||
del config._pastebinfile
|
||||
proxyid = getproxy().newPaste("python", sessionlog)
|
||||
pastebinurl = "%s%s" % (url.show, proxyid)
|
||||
print >>sys.stderr, "session-log:", pastebinurl
|
||||
sys.stderr.write("session-log: %s" % pastebinurl)
|
||||
tr = config.pluginmanager.impname2plugin['terminalreporter']
|
||||
del tr._tw.__dict__['write']
|
||||
|
||||
|
||||
@@ -379,7 +379,7 @@ class ReportRecorder(object):
|
||||
return passed, skipped, failed
|
||||
|
||||
def countoutcomes(self):
|
||||
return map(len, self.listoutcomes())
|
||||
return [len(x) for x in self.listoutcomes()]
|
||||
|
||||
def assertoutcome(self, passed=0, skipped=0, failed=0):
|
||||
realpassed, realskipped, realfailed = self.listoutcomes()
|
||||
|
||||
@@ -426,7 +426,7 @@ class TestDoctest:
|
||||
|
||||
>>> assert abspath
|
||||
>>> i=3
|
||||
>>> print i
|
||||
>>> print (i)
|
||||
3
|
||||
|
||||
yes yes
|
||||
@@ -450,7 +450,7 @@ class TestDoctest:
|
||||
|
||||
def test_doctest_indentation(self, testdir):
|
||||
footxt = testdir.maketxtfile(foo=
|
||||
'..\n >>> print "foo\\n bar"\n foo\n bar\n')
|
||||
'..\n >>> print ("foo\\n bar")\n foo\n bar\n')
|
||||
reprec = testdir.inline_run(footxt)
|
||||
passed, skipped, failed = reprec.countoutcomes()
|
||||
assert failed == 0
|
||||
|
||||
@@ -99,22 +99,22 @@ def test_func_generator_setup(testdir):
|
||||
import sys
|
||||
|
||||
def setup_module(mod):
|
||||
print "setup_module"
|
||||
print ("setup_module")
|
||||
mod.x = []
|
||||
|
||||
def setup_function(fun):
|
||||
print "setup_function"
|
||||
print ("setup_function")
|
||||
x.append(1)
|
||||
|
||||
def teardown_function(fun):
|
||||
print "teardown_function"
|
||||
print ("teardown_function")
|
||||
x.pop()
|
||||
|
||||
def test_one():
|
||||
assert x == [1]
|
||||
def check():
|
||||
print "check"
|
||||
print >>sys.stderr, "e"
|
||||
print ("check")
|
||||
sys.stderr.write("e\\n")
|
||||
assert x == [1]
|
||||
yield check
|
||||
assert x == [1]
|
||||
|
||||
@@ -171,7 +171,7 @@ class TestTerminal:
|
||||
def g():
|
||||
raise IndexError
|
||||
def test_func():
|
||||
print 6*7
|
||||
print (6*7)
|
||||
g() # --calling--
|
||||
""")
|
||||
for tbopt in ["long", "short", "no"]:
|
||||
@@ -179,9 +179,9 @@ class TestTerminal:
|
||||
result = testdir.runpytest('--tb=%s' % tbopt)
|
||||
s = result.stdout.str()
|
||||
if tbopt == "long":
|
||||
assert 'print 6*7' in s
|
||||
assert 'print (6*7)' in s
|
||||
else:
|
||||
assert 'print 6*7' not in s
|
||||
assert 'print (6*7)' not in s
|
||||
if tbopt != "no":
|
||||
assert '--calling--' in s
|
||||
assert 'IndexError' in s
|
||||
@@ -411,7 +411,7 @@ class TestFixtureReporting:
|
||||
def test_setup_fixture_error(self, testdir):
|
||||
p = testdir.makepyfile("""
|
||||
def setup_function(function):
|
||||
print "setup func"
|
||||
print ("setup func")
|
||||
assert 0
|
||||
def test_nada():
|
||||
pass
|
||||
@@ -431,7 +431,7 @@ class TestFixtureReporting:
|
||||
def test_nada():
|
||||
pass
|
||||
def teardown_function(function):
|
||||
print "teardown func"
|
||||
print ("teardown func")
|
||||
assert 0
|
||||
""")
|
||||
result = testdir.runpytest()
|
||||
@@ -450,7 +450,7 @@ class TestFixtureReporting:
|
||||
assert 0, "failingfunc"
|
||||
|
||||
def teardown_function(function):
|
||||
print "teardown func"
|
||||
print ("teardown func")
|
||||
assert False
|
||||
""")
|
||||
result = testdir.runpytest()
|
||||
|
||||
Reference in New Issue
Block a user