Replace py.builtin.print_() calls by builtin print() function
This commit is contained in:
parent
42a5d6bdfa
commit
e5021dc9dc
|
@ -14,8 +14,6 @@ from fnmatch import fnmatch
|
|||
|
||||
from weakref import WeakKeyDictionary
|
||||
|
||||
from py.builtin import print_
|
||||
|
||||
from _pytest.capture import MultiCapture, SysCapture
|
||||
from _pytest._code import Source
|
||||
import py
|
||||
|
@ -231,15 +229,15 @@ class HookRecorder(object):
|
|||
name, check = entries.pop(0)
|
||||
for ind, call in enumerate(self.calls[i:]):
|
||||
if call._name == name:
|
||||
print_("NAMEMATCH", name, call)
|
||||
print("NAMEMATCH", name, call)
|
||||
if eval(check, backlocals, call.__dict__):
|
||||
print_("CHECKERMATCH", repr(check), "->", call)
|
||||
print("CHECKERMATCH", repr(check), "->", call)
|
||||
else:
|
||||
print_("NOCHECKERMATCH", repr(check), "-", call)
|
||||
print("NOCHECKERMATCH", repr(check), "-", call)
|
||||
continue
|
||||
i += ind + 1
|
||||
break
|
||||
print_("NONAMEMATCH", name, "with", call)
|
||||
print("NONAMEMATCH", name, "with", call)
|
||||
else:
|
||||
pytest.fail("could not find %r check %r" % (name, check))
|
||||
|
||||
|
@ -926,8 +924,8 @@ class Testdir(object):
|
|||
cmdargs = [str(x) for x in cmdargs]
|
||||
p1 = self.tmpdir.join("stdout")
|
||||
p2 = self.tmpdir.join("stderr")
|
||||
print_("running:", ' '.join(cmdargs))
|
||||
print_(" in:", str(py.path.local()))
|
||||
print("running:", ' '.join(cmdargs))
|
||||
print(" in:", str(py.path.local()))
|
||||
f1 = codecs.open(str(p1), "w", encoding="utf8")
|
||||
f2 = codecs.open(str(p2), "w", encoding="utf8")
|
||||
try:
|
||||
|
@ -953,7 +951,7 @@ class Testdir(object):
|
|||
def _dump_lines(self, lines, fp):
|
||||
try:
|
||||
for line in lines:
|
||||
py.builtin.print_(line, file=fp)
|
||||
print(line, file=fp)
|
||||
except UnicodeEncodeError:
|
||||
print("couldn't print to %s because of encoding" % (fp,))
|
||||
|
||||
|
|
|
@ -62,9 +62,9 @@ class ResultLog(object):
|
|||
self.logfile = logfile # preferably line buffered
|
||||
|
||||
def write_log_entry(self, testpath, lettercode, longrepr):
|
||||
py.builtin.print_("%s %s" % (lettercode, testpath), file=self.logfile)
|
||||
print("%s %s" % (lettercode, testpath), file=self.logfile)
|
||||
for line in longrepr.splitlines():
|
||||
py.builtin.print_(" %s" % line, file=self.logfile)
|
||||
print(" %s" % line, file=self.logfile)
|
||||
|
||||
def log_outcome(self, report, lettercode, longrepr):
|
||||
testpath = getattr(report, 'nodeid', None)
|
||||
|
|
|
@ -274,6 +274,7 @@ class TestGenerator(object):
|
|||
|
||||
def test_order_of_execution_generator_same_codeline(self, testdir, tmpdir):
|
||||
o = testdir.makepyfile("""
|
||||
from __future__ import print_function
|
||||
def test_generative_order_of_execution():
|
||||
import py, pytest
|
||||
test_list = []
|
||||
|
@ -283,8 +284,8 @@ class TestGenerator(object):
|
|||
test_list.append(item)
|
||||
|
||||
def assert_order_of_execution():
|
||||
py.builtin.print_('expected order', expected_list)
|
||||
py.builtin.print_('but got ', test_list)
|
||||
print('expected order', expected_list)
|
||||
print('but got ', test_list)
|
||||
assert test_list == expected_list
|
||||
|
||||
for i in expected_list:
|
||||
|
@ -298,6 +299,7 @@ class TestGenerator(object):
|
|||
|
||||
def test_order_of_execution_generator_different_codeline(self, testdir):
|
||||
o = testdir.makepyfile("""
|
||||
from __future__ import print_function
|
||||
def test_generative_tests_different_codeline():
|
||||
import py, pytest
|
||||
test_list = []
|
||||
|
@ -313,8 +315,8 @@ class TestGenerator(object):
|
|||
test_list.append(0)
|
||||
|
||||
def assert_order_of_execution():
|
||||
py.builtin.print_('expected order', expected_list)
|
||||
py.builtin.print_('but got ', test_list)
|
||||
print('expected order', expected_list)
|
||||
print('but got ', test_list)
|
||||
assert test_list == expected_list
|
||||
|
||||
yield list_append_0
|
||||
|
|
|
@ -14,7 +14,7 @@ import contextlib
|
|||
from _pytest import capture
|
||||
from _pytest.capture import CaptureManager
|
||||
from _pytest.main import EXIT_NOTESTSCOLLECTED
|
||||
from py.builtin import print_
|
||||
|
||||
|
||||
needsosdup = pytest.mark.xfail("not hasattr(os, 'dup')")
|
||||
|
||||
|
@ -712,7 +712,7 @@ def test_dupfile(tmpfile):
|
|||
assert nf != tmpfile
|
||||
assert nf.fileno() != tmpfile.fileno()
|
||||
assert nf not in flist
|
||||
print_(i, end="", file=nf)
|
||||
print(i, end="", file=nf)
|
||||
flist.append(nf)
|
||||
for i in range(5):
|
||||
f = flist[i]
|
||||
|
@ -786,7 +786,7 @@ class TestFDCapture(object):
|
|||
def test_stderr(self):
|
||||
cap = capture.FDCapture(2)
|
||||
cap.start()
|
||||
print_("hello", file=sys.stderr)
|
||||
print("hello", file=sys.stderr)
|
||||
s = cap.snap()
|
||||
cap.done()
|
||||
assert s == "hello\n"
|
||||
|
|
|
@ -674,7 +674,7 @@ class TestKeywordSelection(object):
|
|||
item.extra_keyword_matches.add("xxx")
|
||||
""")
|
||||
reprec = testdir.inline_run(p.dirpath(), '-s', '-k', keyword)
|
||||
py.builtin.print_("keyword", repr(keyword))
|
||||
print("keyword", repr(keyword))
|
||||
passed, skipped, failed = reprec.listoutcomes()
|
||||
assert len(passed) == 1
|
||||
assert passed[0].nodeid.endswith("test_2")
|
||||
|
|
Loading…
Reference in New Issue