From 4337702a6a8486c2f12e5919cd98a67dc1eccd65 Mon Sep 17 00:00:00 2001 From: "hpk@tannit.openend.se" Date: Fri, 23 Apr 2010 12:05:29 +0200 Subject: [PATCH] fixes for testrun on jython --HG-- branch : trunk --- testing/io_/test_capture.py | 9 +++++++++ testing/io_/test_terminalwriter.py | 9 ++++++--- testing/test_outcome.py | 4 +++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/testing/io_/test_capture.py b/testing/io_/test_capture.py index 03e1b108b..d12e084c2 100644 --- a/testing/io_/test_capture.py +++ b/testing/io_/test_capture.py @@ -1,6 +1,8 @@ import os, sys import py +needsdup = py.test.mark.skipif("not hasattr(os, 'dup')") + from py.builtin import print_ if sys.version_info >= (3,0): @@ -72,6 +74,7 @@ def pytest_funcarg__tmpfile(request): request.addfinalizer(f.close) return f +@needsdup def test_dupfile(tmpfile): somefile = tmpfile flist = [] @@ -91,6 +94,8 @@ def test_dupfile(tmpfile): somefile.close() class TestFDCapture: + pytestmark = needsdup + def test_stdout(self, tmpfile): fd = tmpfile.fileno() cap = py.io.FDCapture(fd) @@ -261,6 +266,8 @@ class TestStdCapture: assert not err class TestStdCaptureFD(TestStdCapture): + pytestmark = needsdup + def getcapture(self, **kw): return py.io.StdCaptureFD(**kw) @@ -289,6 +296,7 @@ class TestStdCaptureFD(TestStdCapture): assert out.startswith("3") assert err.startswith("4") +@needsdup def test_capture_no_sys(): capsys = py.io.StdCapture() try: @@ -303,6 +311,7 @@ def test_capture_no_sys(): finally: capsys.reset() +@needsdup def test_callcapture_nofd(): def func(x, y): oswritebytes(1, "hello") diff --git a/testing/io_/test_terminalwriter.py b/testing/io_/test_terminalwriter.py index 7a5f6c4bb..1710bd3bd 100644 --- a/testing/io_/test_terminalwriter.py +++ b/testing/io_/test_terminalwriter.py @@ -38,9 +38,12 @@ def test_terminalwriter_dumb_term_no_markup(monkeypatch): def isatty(self): return True monkeypatch.setattr(sys, 'stdout', MyFile()) - assert sys.stdout.isatty() - tw = py.io.TerminalWriter() - assert not tw.hasmarkup + try: + assert sys.stdout.isatty() + tw = py.io.TerminalWriter() + assert not tw.hasmarkup + finally: + monkeypatch.undo() def test_unicode_encoding(): msg = py.builtin._totext('b\u00f6y', 'utf8') diff --git a/testing/test_outcome.py b/testing/test_outcome.py index 08c0b9f7a..f415d13c0 100644 --- a/testing/test_outcome.py +++ b/testing/test_outcome.py @@ -68,5 +68,7 @@ def test_pytest_cmdline_main(testdir): py.test.cmdline.main([__file__]) """ % (str(py._pydir.dirpath()))) 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