[py-svn] commit/pytest: hpk42: refine internal test support for unicode-related bits (used by a test in pytest-pep8)
Bitbucket
commits-noreply at bitbucket.org
Thu Sep 20 10:57:30 CEST 2012
1 new commit in pytest:
https://bitbucket.org/hpk42/pytest/changeset/e27845f4a38e/
changeset: e27845f4a38e
user: hpk42
date: 2012-09-20 10:57:23
summary: refine internal test support for unicode-related bits (used by a test in pytest-pep8)
affected #: 3 files
diff -r 32885e1d2189b3bbedfe1a5951c5e1560590d6fe -r e27845f4a38eec31eda20e1a9a20b0900403e0a7 _pytest/__init__.py
--- a/_pytest/__init__.py
+++ b/_pytest/__init__.py
@@ -1,2 +1,2 @@
#
-__version__ = '2.3.0.dev13'
+__version__ = '2.3.0.dev14'
diff -r 32885e1d2189b3bbedfe1a5951c5e1560590d6fe -r e27845f4a38eec31eda20e1a9a20b0900403e0a7 _pytest/pytester.py
--- a/_pytest/pytester.py
+++ b/_pytest/pytester.py
@@ -2,6 +2,7 @@
import py, pytest
import sys, os
+import codecs
import re
import inspect
import time
@@ -244,8 +245,10 @@
ret = None
for name, value in items:
p = self.tmpdir.join(name).new(ext=ext)
- source = py.builtin._totext(py.code.Source(value)).lstrip()
- p.write(source.encode("utf-8"), "wb")
+ source = py.builtin._totext(py.code.Source(value)).strip()
+ content = source.encode("utf-8") # + "\n"
+ #content = content.rstrip() + "\n"
+ p.write(content, "wb")
if ret is None:
ret = p
return ret
@@ -440,28 +443,35 @@
p1 = self.tmpdir.join("stdout")
p2 = self.tmpdir.join("stderr")
print_("running", cmdargs, "curdir=", py.path.local())
- f1 = p1.open("wb")
- f2 = p2.open("wb")
- now = time.time()
- popen = self.popen(cmdargs, stdout=f1, stderr=f2,
- close_fds=(sys.platform != "win32"))
- ret = popen.wait()
- f1.close()
- f2.close()
- out = p1.read("rb")
- out = getdecoded(out).splitlines()
- err = p2.read("rb")
- err = getdecoded(err).splitlines()
- def dump_lines(lines, fp):
- try:
- for line in lines:
- py.builtin.print_(line, file=fp)
- except UnicodeEncodeError:
- print("couldn't print to %s because of encoding" % (fp,))
- dump_lines(out, sys.stdout)
- dump_lines(err, sys.stderr)
+ f1 = codecs.open(str(p1), "w", encoding="utf8")
+ f2 = codecs.open(str(p2), "w", encoding="utf8")
+ try:
+ now = time.time()
+ popen = self.popen(cmdargs, stdout=f1, stderr=f2,
+ close_fds=(sys.platform != "win32"))
+ ret = popen.wait()
+ finally:
+ f1.close()
+ f2.close()
+ f1 = codecs.open(str(p1), "r", encoding="utf8")
+ f2 = codecs.open(str(p2), "r", encoding="utf8")
+ try:
+ out = f1.read().splitlines()
+ err = f2.read().splitlines()
+ finally:
+ f1.close()
+ f2.close()
+ self._dump_lines(out, sys.stdout)
+ self._dump_lines(err, sys.stderr)
return RunResult(ret, out, err, time.time()-now)
+ def _dump_lines(self, lines, fp):
+ try:
+ for line in lines:
+ py.builtin.print_(line, file=fp)
+ except UnicodeEncodeError:
+ print("couldn't print to %s because of encoding" % (fp,))
+
def runpybin(self, scriptname, *args):
fullargs = self._getpybinargs(scriptname) + args
return self.run(*fullargs)
diff -r 32885e1d2189b3bbedfe1a5951c5e1560590d6fe -r e27845f4a38eec31eda20e1a9a20b0900403e0a7 setup.py
--- a/setup.py
+++ b/setup.py
@@ -24,7 +24,7 @@
name='pytest',
description='py.test: simple powerful testing with Python',
long_description = long_description,
- version='2.3.0.dev13',
+ version='2.3.0.dev14',
url='http://pytest.org',
license='MIT license',
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
Repository URL: https://bitbucket.org/hpk42/pytest/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the pytest-commit
mailing list