summaryrefslogtreecommitdiff
path: root/paste/fixture.py
diff options
context:
space:
mode:
authorianb <devnull@localhost>2006-09-22 17:47:10 +0000
committerianb <devnull@localhost>2006-09-22 17:47:10 +0000
commit0b574fd050373ee2666d26f4cc53d736c396e95d (patch)
tree1b8ec007129776a7d9cdc408e0be8f55b61bee1f /paste/fixture.py
parent146192e8ddd9e0d6d2d6a4253949701628a8c00a (diff)
downloadpaste-0b574fd050373ee2666d26f4cc53d736c396e95d.tar.gz
Don't redirect all stdout when running a request -- capture stdout, but also let it go to the real stdout
Diffstat (limited to 'paste/fixture.py')
-rw-r--r--paste/fixture.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/paste/fixture.py b/paste/fixture.py
index 6a28424..e5c7ef0 100644
--- a/paste/fixture.py
+++ b/paste/fixture.py
@@ -312,7 +312,7 @@ class TestApp(object):
req.environ['paste.testing_variables'] = {}
app = lint.middleware(self.app)
old_stdout = sys.stdout
- out = StringIO()
+ out = CaptureStdout(old_stdout)
try:
sys.stdout = out
start_time = time.time()
@@ -376,6 +376,26 @@ class TestApp(object):
return TestResponse(self, status, headers, body, errors,
total_time)
+class CaptureStdout(object):
+
+ def __init__(self, actual):
+ self.captured = StringIO()
+ self.actual = actual
+
+ def write(self, s):
+ self.captured.write(s)
+ self.actual.write(s)
+
+ def flush(self):
+ self.actual.flush()
+
+ def writelines(self, lines):
+ for item in lines:
+ self.write(item)
+
+ def getvalue(self):
+ return self.captured.getvalue()
+
class TestResponse(object):
# for py.test