[pypy-svn] r40335 - in pypy/dist/pypy/translator/goal: . test
arigo at codespeak.net
arigo at codespeak.net
Mon Mar 12 14:29:02 CET 2007
Author: arigo
Date: Mon Mar 12 14:29:00 2007
New Revision: 40335
Added:
pypy/dist/pypy/translator/goal/test/__init__.py (contents, props changed)
pypy/dist/pypy/translator/goal/test/mymodule.py (contents, props changed)
Modified:
pypy/dist/pypy/translator/goal/app_main.py
pypy/dist/pypy/translator/goal/test/test_app_main.py
Log:
More tests for app_main.
Modified: pypy/dist/pypy/translator/goal/app_main.py
==============================================================================
--- pypy/dist/pypy/translator/goal/app_main.py (original)
+++ pypy/dist/pypy/translator/goal/app_main.py Mon Mar 12 14:29:00 2007
@@ -239,7 +239,7 @@
try:
import site
except:
- print >> sys.stderr, "import site' failed"
+ print >> sys.stderr, "'import site' failed"
# set up the Ctrl-C => KeyboardInterrupt signal handler, if the
@@ -353,6 +353,7 @@
if __name__ == '__main__':
+ import autopath
# obscure! try removing the following line, see how it crashes, and
# guess why...
ImStillAroundDontForgetMe = sys.modules['__main__']
Added: pypy/dist/pypy/translator/goal/test/__init__.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/goal/test/__init__.py Mon Mar 12 14:29:00 2007
@@ -0,0 +1 @@
+#empty
Added: pypy/dist/pypy/translator/goal/test/mymodule.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/goal/test/mymodule.py Mon Mar 12 14:29:00 2007
@@ -0,0 +1,10 @@
+# for test_app_main
+
+import sys
+
+print 'mymodule running'
+print 'Name:', __name__
+print 'File:', __file__
+print 'Argv:', sys.argv
+
+somevalue = "foobar"
Modified: pypy/dist/pypy/translator/goal/test/test_app_main.py
==============================================================================
--- pypy/dist/pypy/translator/goal/test/test_app_main.py (original)
+++ pypy/dist/pypy/translator/goal/test/test_app_main.py Mon Mar 12 14:29:00 2007
@@ -206,6 +206,33 @@
finally:
os.environ['PYTHONSTARTUP'] = old
+ def test_unbuffered(self):
+ line = 'import os,sys;sys.stdout.write(str(789));os.read(0,1)'
+ child = self.spawn(['-u', '-c', line])
+ child.expect('789') # expect to see it before the timeout hits
+ child.sendline('X')
+
+ def test_options_i_m(self):
+ p = os.path.join(autopath.this_dir, 'mymodule.py')
+ p = os.path.abspath(p)
+ child = self.spawn(['-i',
+ '-m', 'pypy.translator.goal.test.mymodule',
+ 'extra'])
+ child.expect('mymodule running')
+ child.expect('Name: __main__')
+ child.expect(re.escape('File: ' + p))
+ child.expect(re.escape('Argv: ' + repr([p, 'extra'])))
+ child.expect('>>> ')
+ #XXX the following doesn't work on CPython 2.5 either
+ #child.sendline('somevalue')
+ #child.expect(re.escape(repr("foobar")))
+ #child.expect('>>> ')
+ child.sendline('import sys')
+ child.sendline('"pypy.translator.goal.test" in sys.modules')
+ child.expect('True')
+ child.sendline('"pypy.translator.goal.test.mymodule" in sys.modules')
+ child.expect('False')
+
class TestNonInteractive:
@@ -260,3 +287,12 @@
assert 'Hello2' not in data
finally:
os.environ['PYTHONSTARTUP'] = old
+
+ def test_option_m(self):
+ p = os.path.join(autopath.this_dir, 'mymodule.py')
+ p = os.path.abspath(p)
+ data = self.run('-m pypy.translator.goal.test.mymodule extra')
+ assert 'mymodule running' in data
+ assert 'Name: __main__' in data
+ assert ('File: ' + p) in data
+ assert ('Argv: ' + repr([p, 'extra'])) in data
More information about the Pypy-commit
mailing list