Skip to content

Commit

Permalink
fixed a bunch of unicode bugs in pytester.py
Browse files Browse the repository at this point in the history
  • Loading branch information
wimglenn committed Aug 22, 2018
1 parent f1079a8 commit 18fcfdc
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/_pytest/pytester.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from _pytest.main import Session, EXIT_OK
from _pytest.assertion.rewrite import AssertionRewritingHook
from _pytest.compat import Path
from _pytest.compat import safe_str

IGNORE_PAM = [ # filenames added when obtaining details about the current user
u"/var/lib/sss/mc/passwd"
Expand All @@ -34,7 +35,7 @@ def pytest_addoption(parser):
action="store_true",
dest="lsof",
default=False,
help=("run FD checks if lsof is available"),
help="run FD checks if lsof is available",
)

parser.addoption(
Expand Down Expand Up @@ -273,7 +274,7 @@ def popcall(self, name):
del self.calls[i]
return call
lines = ["could not find call %r, in:" % (name,)]
lines.extend([" %s" % str(x) for x in self.calls])
lines.extend([" %s" % x for x in self.calls])
pytest.fail("\n".join(lines))

def getcall(self, name):
Expand Down Expand Up @@ -885,14 +886,12 @@ def runpytest(self, *args, **kwargs):
return self._runpytest_method(*args, **kwargs)

def _ensure_basetemp(self, args):
args = [str(x) for x in args]
args = list(args)
for x in args:
if str(x).startswith("--basetemp"):
# print("basedtemp exists: %s" %(args,))
if safe_str(x).startswith("--basetemp"):
break
else:
args.append("--basetemp=%s" % self.tmpdir.dirpath("basetemp"))
# print("added basetemp: %s" %(args,))
return args

def parseconfig(self, *args):
Expand Down Expand Up @@ -1018,7 +1017,7 @@ def popen(self, cmdargs, stdout, stderr, **kw):
"""
env = os.environ.copy()
env["PYTHONPATH"] = os.pathsep.join(
filter(None, [str(os.getcwd()), env.get("PYTHONPATH", "")])
filter(None, [os.getcwd(), env.get("PYTHONPATH", "")])
)
kw["env"] = env

Expand All @@ -1040,11 +1039,13 @@ def run(self, *cmdargs):
return self._run(*cmdargs)

def _run(self, *cmdargs):
cmdargs = [str(x) for x in cmdargs]
cmdargs = [
str(arg) if isinstance(arg, py.path.local) else arg for arg in cmdargs
]
p1 = self.tmpdir.join("stdout")
p2 = self.tmpdir.join("stderr")
print("running:", " ".join(cmdargs))
print(" in:", str(py.path.local()))
print("running:", *cmdargs)
print(" in:", py.path.local())
f1 = codecs.open(str(p1), "w", encoding="utf8")
f2 = codecs.open(str(p2), "w", encoding="utf8")
try:
Expand Down

0 comments on commit 18fcfdc

Please sign in to comment.