[pypy-svn] rev 487 - pypy/trunk/src/pypy/interpreter/test
pedronis at codespeak.net
pedronis at codespeak.net
Mon May 26 19:41:47 CEST 2003
Author: pedronis
Date: Mon May 26 19:41:46 2003
New Revision: 487
Modified:
pypy/trunk/src/pypy/interpreter/test/test_main.py
Log:
working test for print len(aStr) where aStr = 'hello world'
Modified: pypy/trunk/src/pypy/interpreter/test/test_main.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/test/test_main.py (original)
+++ pypy/trunk/src/pypy/interpreter/test/test_main.py Mon May 26 19:41:46 2003
@@ -1,5 +1,6 @@
import unittest
-import support
+import testsupport
+from cStringIO import StringIO
from pypy.interpreter.baseobjspace import OperationError
@@ -11,6 +12,22 @@
main()
"""
+testresultoutput = '11\n'
+
+capture = StringIO()
+
+def checkoutput(expected_output,f,*args):
+ import sys
+ oldout = sys.stdout
+ try:
+ capture.reset()
+ sys.stdout = capture
+ f(*args)
+ finally:
+ sys.stdout = oldout
+
+ return capture.getvalue() == expected_output
+
testfn = 'tmp_hello_world.py'
class TestMain(unittest.TestCase):
@@ -26,16 +43,12 @@
def test_run_file(self):
from pypy.interpreter import main
- self.assertRaises(OperationError,
- main.run_file,
- testfn)
+ self.assert_(checkoutput(testresultoutput,main.run_file,testfn))
def test_run_string(self):
from pypy.interpreter import main
- self.assertRaises(OperationError,
- main.run_string,
- testcode,
- testfn)
+ self.assert_(checkoutput(testresultoutput,
+ main.run_string,testcode,testfn))
if __name__ == '__main__':
unittest.main()
More information about the Pypy-commit
mailing list