some py3 encoding fixes
Also return True if fnmatch succeeds. --HG-- branch : trunk
This commit is contained in:
parent
22a50a5b88
commit
f2be437daa
|
@ -116,8 +116,8 @@ class TmpTestdir:
|
||||||
ret = None
|
ret = None
|
||||||
for name, value in items:
|
for name, value in items:
|
||||||
p = self.tmpdir.join(name).new(ext=ext)
|
p = self.tmpdir.join(name).new(ext=ext)
|
||||||
source = py.code.Source(value)
|
source = str(py.code.Source(value)).lstrip()
|
||||||
p.write(str(py.code.Source(value)).lstrip())
|
p.write(source.encode("utf-8"), "wb")
|
||||||
if ret is None:
|
if ret is None:
|
||||||
ret = p
|
ret = p
|
||||||
return ret
|
return ret
|
||||||
|
@ -286,15 +286,16 @@ class TmpTestdir:
|
||||||
p1 = self.tmpdir.join("stdout")
|
p1 = self.tmpdir.join("stdout")
|
||||||
p2 = self.tmpdir.join("stderr")
|
p2 = self.tmpdir.join("stderr")
|
||||||
print_("running", cmdargs, "curdir=", py.path.local())
|
print_("running", cmdargs, "curdir=", py.path.local())
|
||||||
f1 = p1.open("w")
|
f1 = p1.open("wb")
|
||||||
f2 = p2.open("w")
|
f2 = p2.open("wb")
|
||||||
now = time.time()
|
now = time.time()
|
||||||
popen = self.popen(cmdargs, stdout=f1, stderr=f2,
|
popen = self.popen(cmdargs, stdout=f1, stderr=f2,
|
||||||
close_fds=(sys.platform != "win32"))
|
close_fds=(sys.platform != "win32"))
|
||||||
ret = popen.wait()
|
ret = popen.wait()
|
||||||
f1.close()
|
f1.close()
|
||||||
f2.close()
|
f2.close()
|
||||||
out, err = p1.readlines(cr=0), p2.readlines(cr=0)
|
out = p1.read("rb").decode("utf-8").splitlines()
|
||||||
|
err = p2.read("rb").decode("utf-8").splitlines()
|
||||||
if err:
|
if err:
|
||||||
for line in err:
|
for line in err:
|
||||||
py.builtin.print_(line, file=sys.stderr)
|
py.builtin.print_(line, file=sys.stderr)
|
||||||
|
@ -462,10 +463,10 @@ class LineMatcher:
|
||||||
lines2 = lines2.strip().lines
|
lines2 = lines2.strip().lines
|
||||||
|
|
||||||
from fnmatch import fnmatch
|
from fnmatch import fnmatch
|
||||||
__tracebackhide__ = True
|
|
||||||
lines1 = self.lines[:]
|
lines1 = self.lines[:]
|
||||||
nextline = None
|
nextline = None
|
||||||
extralines = []
|
extralines = []
|
||||||
|
__tracebackhide__ = True
|
||||||
for line in lines2:
|
for line in lines2:
|
||||||
nomatchprinted = False
|
nomatchprinted = False
|
||||||
while lines1:
|
while lines1:
|
||||||
|
@ -484,8 +485,5 @@ class LineMatcher:
|
||||||
print_(" and:", repr(nextline))
|
print_(" and:", repr(nextline))
|
||||||
extralines.append(nextline)
|
extralines.append(nextline)
|
||||||
else:
|
else:
|
||||||
if line != nextline:
|
assert line == nextline
|
||||||
#__tracebackhide__ = True
|
return True
|
||||||
raise AssertionError("expected line not found: %r" % line)
|
|
||||||
extralines.extend(lines1)
|
|
||||||
return extralines
|
|
||||||
|
|
Loading…
Reference in New Issue