fixes for testrun on jython

--HG--
branch : trunk
This commit is contained in:
hpk@tannit.openend.se 2010-04-23 12:05:29 +02:00
parent ff90b1b4fb
commit 4337702a6a
3 changed files with 18 additions and 4 deletions

View File

@ -1,6 +1,8 @@
import os, sys import os, sys
import py import py
needsdup = py.test.mark.skipif("not hasattr(os, 'dup')")
from py.builtin import print_ from py.builtin import print_
if sys.version_info >= (3,0): if sys.version_info >= (3,0):
@ -72,6 +74,7 @@ def pytest_funcarg__tmpfile(request):
request.addfinalizer(f.close) request.addfinalizer(f.close)
return f return f
@needsdup
def test_dupfile(tmpfile): def test_dupfile(tmpfile):
somefile = tmpfile somefile = tmpfile
flist = [] flist = []
@ -91,6 +94,8 @@ def test_dupfile(tmpfile):
somefile.close() somefile.close()
class TestFDCapture: class TestFDCapture:
pytestmark = needsdup
def test_stdout(self, tmpfile): def test_stdout(self, tmpfile):
fd = tmpfile.fileno() fd = tmpfile.fileno()
cap = py.io.FDCapture(fd) cap = py.io.FDCapture(fd)
@ -261,6 +266,8 @@ class TestStdCapture:
assert not err assert not err
class TestStdCaptureFD(TestStdCapture): class TestStdCaptureFD(TestStdCapture):
pytestmark = needsdup
def getcapture(self, **kw): def getcapture(self, **kw):
return py.io.StdCaptureFD(**kw) return py.io.StdCaptureFD(**kw)
@ -289,6 +296,7 @@ class TestStdCaptureFD(TestStdCapture):
assert out.startswith("3") assert out.startswith("3")
assert err.startswith("4") assert err.startswith("4")
@needsdup
def test_capture_no_sys(): def test_capture_no_sys():
capsys = py.io.StdCapture() capsys = py.io.StdCapture()
try: try:
@ -303,6 +311,7 @@ def test_capture_no_sys():
finally: finally:
capsys.reset() capsys.reset()
@needsdup
def test_callcapture_nofd(): def test_callcapture_nofd():
def func(x, y): def func(x, y):
oswritebytes(1, "hello") oswritebytes(1, "hello")

View File

@ -38,9 +38,12 @@ def test_terminalwriter_dumb_term_no_markup(monkeypatch):
def isatty(self): def isatty(self):
return True return True
monkeypatch.setattr(sys, 'stdout', MyFile()) monkeypatch.setattr(sys, 'stdout', MyFile())
assert sys.stdout.isatty() try:
tw = py.io.TerminalWriter() assert sys.stdout.isatty()
assert not tw.hasmarkup tw = py.io.TerminalWriter()
assert not tw.hasmarkup
finally:
monkeypatch.undo()
def test_unicode_encoding(): def test_unicode_encoding():
msg = py.builtin._totext('b\u00f6y', 'utf8') msg = py.builtin._totext('b\u00f6y', 'utf8')

View File

@ -68,5 +68,7 @@ def test_pytest_cmdline_main(testdir):
py.test.cmdline.main([__file__]) py.test.cmdline.main([__file__])
""" % (str(py._pydir.dirpath()))) """ % (str(py._pydir.dirpath())))
import subprocess import subprocess
ret = subprocess.call([sys.executable, str(p)]) popen = subprocess.Popen([sys.executable, str(p)], stdout=subprocess.PIPE)
s = popen.stdout.read()
ret = popen.wait()
assert ret == 0 assert ret == 0