Commits

Brian Kearns committed 8f0c8d1

move the pyrepl tests to test_lib_pypy so they have a hope of being executed

  • Participants
  • Parent commits b93922f

Comments (0)

Files changed (12)

lib_pypy/pyrepl/test/test_functional.py

-#   Copyright 2000-2007 Michael Hudson-Doyle <micahel@gmail.com>
-#                       Maciek Fijalkowski
-#
-#                        All Rights Reserved
-#
-#
-# Permission to use, copy, modify, and distribute this software and
-# its documentation for any purpose is hereby granted without fee,
-# provided that the above copyright notice appear in all copies and
-# that both that copyright notice and this permission notice appear in
-# supporting documentation.
-#
-# THE AUTHOR MICHAEL HUDSON DISCLAIMS ALL WARRANTIES WITH REGARD TO
-# THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-# AND FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL,
-# INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
-# RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
-# CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
-# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-# some functional tests, to see if this is really working
-
-import py
-import sys
-
-class TestTerminal(object):
-    def _spawn(self, *args, **kwds):
-        try:
-            import pexpect
-        except ImportError, e:
-            py.test.skip(str(e))
-        kwds.setdefault('timeout', 10)
-        child = pexpect.spawn(*args, **kwds)
-        child.logfile = sys.stdout
-        return child
-
-    def spawn(self, argv=[]):
-        # avoid running start.py, cause it might contain
-        # things like readline or rlcompleter(2) included
-        child = self._spawn(sys.executable, ['-S'] + argv)
-        child.sendline('from pyrepl.python_reader import main')
-        child.sendline('main()')
-        return child
-
-    def test_basic(self):
-        child = self.spawn()
-        child.sendline('a = 3')
-        child.sendline('a')
-        child.expect('3')
-        

lib_pypy/pyrepl/tests/__init__.py

-#   Copyright 2000-2004 Michael Hudson-Doyle <micahel@gmail.com>
-#
-#                        All Rights Reserved
-#
-#
-# Permission to use, copy, modify, and distribute this software and
-# its documentation for any purpose is hereby granted without fee,
-# provided that the above copyright notice appear in all copies and
-# that both that copyright notice and this permission notice appear in
-# supporting documentation.
-#
-# THE AUTHOR MICHAEL HUDSON DISCLAIMS ALL WARRANTIES WITH REGARD TO
-# THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-# AND FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL,
-# INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
-# RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
-# CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
-# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-# moo

lib_pypy/pyrepl/tests/basic.py

-#   Copyright 2000-2004 Michael Hudson-Doyle <micahel@gmail.com>
-#
-#                        All Rights Reserved
-#
-#
-# Permission to use, copy, modify, and distribute this software and
-# its documentation for any purpose is hereby granted without fee,
-# provided that the above copyright notice appear in all copies and
-# that both that copyright notice and this permission notice appear in
-# supporting documentation.
-#
-# THE AUTHOR MICHAEL HUDSON DISCLAIMS ALL WARRANTIES WITH REGARD TO
-# THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-# AND FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL,
-# INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
-# RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
-# CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
-# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-from pyrepl.console import Event
-from pyrepl.tests.infrastructure import ReaderTestCase, EA, run_testcase
-
-class SimpleTestCase(ReaderTestCase):
-
-    def test_basic(self):
-        self.run_test([(('self-insert', 'a'), ['a']),
-                       ( 'accept',            ['a'])])
-
-    def test_repeat(self):
-        self.run_test([(('digit-arg', '3'),   ['']),
-                       (('self-insert', 'a'), ['aaa']),
-                       ( 'accept',            ['aaa'])])
-
-    def test_kill_line(self):
-        self.run_test([(('self-insert', 'abc'), ['abc']),
-                       ( 'left',                None),
-                       ( 'kill-line',           ['ab']),
-                       ( 'accept',              ['ab'])])
-
-    def test_unix_line_discard(self):
-        self.run_test([(('self-insert', 'abc'), ['abc']),
-                       ( 'left',                None),
-                       ( 'unix-word-rubout',    ['c']),
-                       ( 'accept',              ['c'])])
-
-    def test_kill_word(self):
-        self.run_test([(('self-insert', 'ab cd'), ['ab cd']),
-                       ( 'beginning-of-line',     ['ab cd']),
-                       ( 'kill-word',             [' cd']),
-                       ( 'accept',                [' cd'])])
-
-    def test_backward_kill_word(self):
-        self.run_test([(('self-insert', 'ab cd'), ['ab cd']),
-                       ( 'backward-kill-word',    ['ab ']),
-                       ( 'accept',                ['ab '])])
-
-    def test_yank(self):
-        self.run_test([(('self-insert', 'ab cd'), ['ab cd']),
-                       ( 'backward-kill-word',    ['ab ']),
-                       ( 'beginning-of-line',     ['ab ']),
-                       ( 'yank',                  ['cdab ']),
-                       ( 'accept',                ['cdab '])])
-        
-    def test_yank_pop(self):
-        self.run_test([(('self-insert', 'ab cd'), ['ab cd']),
-                       ( 'backward-kill-word',    ['ab ']),
-                       ( 'left',                  ['ab ']),
-                       ( 'backward-kill-word',    [' ']),
-                       ( 'yank',                  ['ab ']),
-                       ( 'yank-pop',              ['cd ']),
-                       ( 'accept',                ['cd '])])
-
-    def test_interrupt(self):
-        try:
-            self.run_test([( 'interrupt',  [''])])
-        except KeyboardInterrupt:
-            pass
-        else:
-            self.fail('KeyboardInterrupt got lost')
-
-    # test_suspend -- hah
-
-    def test_up(self):
-        self.run_test([(('self-insert', 'ab\ncd'), ['ab', 'cd']),
-                       ( 'up',                     ['ab', 'cd']),
-                       (('self-insert', 'e'),      ['abe', 'cd']),
-                       ( 'accept',                 ['abe', 'cd'])])
-
-    def test_down(self):
-        self.run_test([(('self-insert', 'ab\ncd'), ['ab', 'cd']),
-                       ( 'up',                     ['ab', 'cd']),
-                       (('self-insert', 'e'),      ['abe', 'cd']),
-                       ( 'down',                   ['abe', 'cd']),
-                       (('self-insert', 'f'),      ['abe', 'cdf']),
-                       ( 'accept',                 ['abe', 'cdf'])])
-
-    def test_left(self):
-        self.run_test([(('self-insert', 'ab'), ['ab']),
-                       ( 'left',               ['ab']),
-                       (('self-insert', 'c'),  ['acb']),
-                       ( 'accept',             ['acb'])])
-
-    def test_right(self):
-        self.run_test([(('self-insert', 'ab'), ['ab']),
-                       ( 'left',               ['ab']),
-                       (('self-insert', 'c'),  ['acb']),
-                       ( 'right',              ['acb']),
-                       (('self-insert', 'd'),  ['acbd']),
-                       ( 'accept',             ['acbd'])])
-        
-def test():
-    run_testcase(SimpleTestCase)
-
-if __name__ == '__main__':
-    test()

lib_pypy/pyrepl/tests/bugs.py

-#   Copyright 2000-2004 Michael Hudson-Doyle <micahel@gmail.com>
-#
-#                        All Rights Reserved
-#
-#
-# Permission to use, copy, modify, and distribute this software and
-# its documentation for any purpose is hereby granted without fee,
-# provided that the above copyright notice appear in all copies and
-# that both that copyright notice and this permission notice appear in
-# supporting documentation.
-#
-# THE AUTHOR MICHAEL HUDSON DISCLAIMS ALL WARRANTIES WITH REGARD TO
-# THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-# AND FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL,
-# INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
-# RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
-# CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
-# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-from pyrepl.console import Event
-from pyrepl.tests.infrastructure import ReaderTestCase, EA, run_testcase
-
-# this test case should contain as-verbatim-as-possible versions of
-# (applicable) bug reports
-
-class BugsTestCase(ReaderTestCase):
-
-    def test_transpose_at_start(self):
-        self.run_test([( 'transpose', [EA, '']),
-                       ( 'accept',    [''])])
-
-def test():
-    run_testcase(BugsTestCase)
-
-if __name__ == '__main__':
-    test()

lib_pypy/pyrepl/tests/infrastructure.py

-#   Copyright 2000-2004 Michael Hudson-Doyle <micahel@gmail.com>
-#
-#                        All Rights Reserved
-#
-#
-# Permission to use, copy, modify, and distribute this software and
-# its documentation for any purpose is hereby granted without fee,
-# provided that the above copyright notice appear in all copies and
-# that both that copyright notice and this permission notice appear in
-# supporting documentation.
-#
-# THE AUTHOR MICHAEL HUDSON DISCLAIMS ALL WARRANTIES WITH REGARD TO
-# THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-# AND FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL,
-# INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
-# RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
-# CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
-# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-from pyrepl.reader import Reader
-from pyrepl.console import Console, Event
-import unittest
-import sys
-
-class EqualsAnything(object):
-    def __eq__(self, other):
-        return True
-EA = EqualsAnything()
-
-class TestConsole(Console):
-    height = 24
-    width = 80
-    encoding = 'utf-8'
-
-    def __init__(self, events, testcase, verbose=False):
-        self.events = events
-        self.next_screen = None
-        self.verbose = verbose
-        self.testcase = testcase
-
-    def refresh(self, screen, xy):
-        if self.next_screen is not None:
-            self.testcase.assertEqual(
-                screen, self.next_screen,
-                "[ %s != %s after %r ]"%(screen, self.next_screen,
-                                         self.last_event_name))
-
-    def get_event(self, block=1):
-        ev, sc = self.events.pop(0)
-        self.next_screen = sc
-        if not isinstance(ev, tuple):
-            ev = (ev,)
-        self.last_event_name = ev[0]
-        if self.verbose:
-            print "event", ev
-        return Event(*ev)
-
-class TestReader(Reader):
-    def get_prompt(self, lineno, cursor_on_line):
-        return ''
-    def refresh(self):
-        Reader.refresh(self)
-        self.dirty = True
-
-class ReaderTestCase(unittest.TestCase):
-    def run_test(self, test_spec, reader_class=TestReader):
-        # remember to finish your test_spec with 'accept' or similar!
-        con = TestConsole(test_spec, self)
-        reader = reader_class(con)
-        reader.readline()
-
-class BasicTestRunner:
-    def run(self, test):
-        result = unittest.TestResult()
-        test(result)
-        return result
-
-def run_testcase(testclass):
-    suite = unittest.makeSuite(testclass)
-    runner = unittest.TextTestRunner(sys.stdout, verbosity=1)
-    result = runner.run(suite)
-    

lib_pypy/pyrepl/tests/wishes.py

-#   Copyright 2000-2004 Michael Hudson-Doyle <micahel@gmail.com>
-#
-#                        All Rights Reserved
-#
-#
-# Permission to use, copy, modify, and distribute this software and
-# its documentation for any purpose is hereby granted without fee,
-# provided that the above copyright notice appear in all copies and
-# that both that copyright notice and this permission notice appear in
-# supporting documentation.
-#
-# THE AUTHOR MICHAEL HUDSON DISCLAIMS ALL WARRANTIES WITH REGARD TO
-# THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-# AND FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL,
-# INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
-# RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
-# CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
-# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-from pyrepl.console import Event
-from pyrepl.tests.infrastructure import ReaderTestCase, EA, run_testcase
-
-# this test case should contain as-verbatim-as-possible versions of
-# (applicable) feature requests
-
-class WishesTestCase(ReaderTestCase):
-
-    def test_quoted_insert_repeat(self):
-        self.run_test([(('digit-arg', '3'),      ['']),
-                       ( 'quoted-insert',        ['']),
-                       (('self-insert', '\033'), ['^[^[^[']),
-                       ( 'accept',               None)])
-
-def test():
-    run_testcase(WishesTestCase)
-
-if __name__ == '__main__':
-    test()

pypy/module/test_lib_pypy/pyrepl/__init__.py

+#   Copyright 2000-2004 Michael Hudson-Doyle <micahel@gmail.com>
+#
+#                        All Rights Reserved
+#
+#
+# Permission to use, copy, modify, and distribute this software and
+# its documentation for any purpose is hereby granted without fee,
+# provided that the above copyright notice appear in all copies and
+# that both that copyright notice and this permission notice appear in
+# supporting documentation.
+#
+# THE AUTHOR MICHAEL HUDSON DISCLAIMS ALL WARRANTIES WITH REGARD TO
+# THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+# AND FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL,
+# INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+# RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+# CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+# moo

pypy/module/test_lib_pypy/pyrepl/infrastructure.py

+#   Copyright 2000-2004 Michael Hudson-Doyle <micahel@gmail.com>
+#
+#                        All Rights Reserved
+#
+#
+# Permission to use, copy, modify, and distribute this software and
+# its documentation for any purpose is hereby granted without fee,
+# provided that the above copyright notice appear in all copies and
+# that both that copyright notice and this permission notice appear in
+# supporting documentation.
+#
+# THE AUTHOR MICHAEL HUDSON DISCLAIMS ALL WARRANTIES WITH REGARD TO
+# THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+# AND FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL,
+# INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+# RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+# CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+from pyrepl.reader import Reader
+from pyrepl.console import Console, Event
+import unittest
+import sys
+
+class EqualsAnything(object):
+    def __eq__(self, other):
+        return True
+EA = EqualsAnything()
+
+class TestConsole(Console):
+    height = 24
+    width = 80
+    encoding = 'utf-8'
+
+    def __init__(self, events, testcase, verbose=False):
+        self.events = events
+        self.next_screen = None
+        self.verbose = verbose
+        self.testcase = testcase
+
+    def refresh(self, screen, xy):
+        if self.next_screen is not None:
+            self.testcase.assertEqual(
+                screen, self.next_screen,
+                "[ %s != %s after %r ]"%(screen, self.next_screen,
+                                         self.last_event_name))
+
+    def get_event(self, block=1):
+        ev, sc = self.events.pop(0)
+        self.next_screen = sc
+        if not isinstance(ev, tuple):
+            ev = (ev,)
+        self.last_event_name = ev[0]
+        if self.verbose:
+            print "event", ev
+        return Event(*ev)
+
+class TestReader(Reader):
+    def get_prompt(self, lineno, cursor_on_line):
+        return ''
+    def refresh(self):
+        Reader.refresh(self)
+        self.dirty = True
+
+class ReaderTestCase(unittest.TestCase):
+    def run_test(self, test_spec, reader_class=TestReader):
+        # remember to finish your test_spec with 'accept' or similar!
+        con = TestConsole(test_spec, self)
+        reader = reader_class(con)
+        reader.readline()
+
+class BasicTestRunner:
+    def run(self, test):
+        result = unittest.TestResult()
+        test(result)
+        return result
+
+def run_testcase(testclass):
+    suite = unittest.makeSuite(testclass)
+    runner = unittest.TextTestRunner(sys.stdout, verbosity=1)
+    result = runner.run(suite)
+    

pypy/module/test_lib_pypy/pyrepl/test_basic.py

+#   Copyright 2000-2004 Michael Hudson-Doyle <micahel@gmail.com>
+#
+#                        All Rights Reserved
+#
+#
+# Permission to use, copy, modify, and distribute this software and
+# its documentation for any purpose is hereby granted without fee,
+# provided that the above copyright notice appear in all copies and
+# that both that copyright notice and this permission notice appear in
+# supporting documentation.
+#
+# THE AUTHOR MICHAEL HUDSON DISCLAIMS ALL WARRANTIES WITH REGARD TO
+# THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+# AND FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL,
+# INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+# RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+# CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+from pyrepl.console import Event
+from pyrepl.tests.infrastructure import ReaderTestCase, EA, run_testcase
+
+class SimpleTestCase(ReaderTestCase):
+
+    def test_basic(self):
+        self.run_test([(('self-insert', 'a'), ['a']),
+                       ( 'accept',            ['a'])])
+
+    def test_repeat(self):
+        self.run_test([(('digit-arg', '3'),   ['']),
+                       (('self-insert', 'a'), ['aaa']),
+                       ( 'accept',            ['aaa'])])
+
+    def test_kill_line(self):
+        self.run_test([(('self-insert', 'abc'), ['abc']),
+                       ( 'left',                None),
+                       ( 'kill-line',           ['ab']),
+                       ( 'accept',              ['ab'])])
+
+    def test_unix_line_discard(self):
+        self.run_test([(('self-insert', 'abc'), ['abc']),
+                       ( 'left',                None),
+                       ( 'unix-word-rubout',    ['c']),
+                       ( 'accept',              ['c'])])
+
+    def test_kill_word(self):
+        self.run_test([(('self-insert', 'ab cd'), ['ab cd']),
+                       ( 'beginning-of-line',     ['ab cd']),
+                       ( 'kill-word',             [' cd']),
+                       ( 'accept',                [' cd'])])
+
+    def test_backward_kill_word(self):
+        self.run_test([(('self-insert', 'ab cd'), ['ab cd']),
+                       ( 'backward-kill-word',    ['ab ']),
+                       ( 'accept',                ['ab '])])
+
+    def test_yank(self):
+        self.run_test([(('self-insert', 'ab cd'), ['ab cd']),
+                       ( 'backward-kill-word',    ['ab ']),
+                       ( 'beginning-of-line',     ['ab ']),
+                       ( 'yank',                  ['cdab ']),
+                       ( 'accept',                ['cdab '])])
+        
+    def test_yank_pop(self):
+        self.run_test([(('self-insert', 'ab cd'), ['ab cd']),
+                       ( 'backward-kill-word',    ['ab ']),
+                       ( 'left',                  ['ab ']),
+                       ( 'backward-kill-word',    [' ']),
+                       ( 'yank',                  ['ab ']),
+                       ( 'yank-pop',              ['cd ']),
+                       ( 'accept',                ['cd '])])
+
+    def test_interrupt(self):
+        try:
+            self.run_test([( 'interrupt',  [''])])
+        except KeyboardInterrupt:
+            pass
+        else:
+            self.fail('KeyboardInterrupt got lost')
+
+    # test_suspend -- hah
+
+    def test_up(self):
+        self.run_test([(('self-insert', 'ab\ncd'), ['ab', 'cd']),
+                       ( 'up',                     ['ab', 'cd']),
+                       (('self-insert', 'e'),      ['abe', 'cd']),
+                       ( 'accept',                 ['abe', 'cd'])])
+
+    def test_down(self):
+        self.run_test([(('self-insert', 'ab\ncd'), ['ab', 'cd']),
+                       ( 'up',                     ['ab', 'cd']),
+                       (('self-insert', 'e'),      ['abe', 'cd']),
+                       ( 'down',                   ['abe', 'cd']),
+                       (('self-insert', 'f'),      ['abe', 'cdf']),
+                       ( 'accept',                 ['abe', 'cdf'])])
+
+    def test_left(self):
+        self.run_test([(('self-insert', 'ab'), ['ab']),
+                       ( 'left',               ['ab']),
+                       (('self-insert', 'c'),  ['acb']),
+                       ( 'accept',             ['acb'])])
+
+    def test_right(self):
+        self.run_test([(('self-insert', 'ab'), ['ab']),
+                       ( 'left',               ['ab']),
+                       (('self-insert', 'c'),  ['acb']),
+                       ( 'right',              ['acb']),
+                       (('self-insert', 'd'),  ['acbd']),
+                       ( 'accept',             ['acbd'])])
+        
+def test():
+    run_testcase(SimpleTestCase)
+
+if __name__ == '__main__':
+    test()

pypy/module/test_lib_pypy/pyrepl/test_bugs.py

+#   Copyright 2000-2004 Michael Hudson-Doyle <micahel@gmail.com>
+#
+#                        All Rights Reserved
+#
+#
+# Permission to use, copy, modify, and distribute this software and
+# its documentation for any purpose is hereby granted without fee,
+# provided that the above copyright notice appear in all copies and
+# that both that copyright notice and this permission notice appear in
+# supporting documentation.
+#
+# THE AUTHOR MICHAEL HUDSON DISCLAIMS ALL WARRANTIES WITH REGARD TO
+# THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+# AND FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL,
+# INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+# RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+# CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+from pyrepl.console import Event
+from pyrepl.tests.infrastructure import ReaderTestCase, EA, run_testcase
+
+# this test case should contain as-verbatim-as-possible versions of
+# (applicable) bug reports
+
+class BugsTestCase(ReaderTestCase):
+
+    def test_transpose_at_start(self):
+        self.run_test([( 'transpose', [EA, '']),
+                       ( 'accept',    [''])])
+
+def test():
+    run_testcase(BugsTestCase)
+
+if __name__ == '__main__':
+    test()

pypy/module/test_lib_pypy/pyrepl/test_functional.py

+#   Copyright 2000-2007 Michael Hudson-Doyle <micahel@gmail.com>
+#                       Maciek Fijalkowski
+#
+#                        All Rights Reserved
+#
+#
+# Permission to use, copy, modify, and distribute this software and
+# its documentation for any purpose is hereby granted without fee,
+# provided that the above copyright notice appear in all copies and
+# that both that copyright notice and this permission notice appear in
+# supporting documentation.
+#
+# THE AUTHOR MICHAEL HUDSON DISCLAIMS ALL WARRANTIES WITH REGARD TO
+# THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+# AND FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL,
+# INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+# RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+# CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+# some functional tests, to see if this is really working
+
+import py
+import sys
+
+class TestTerminal(object):
+    def _spawn(self, *args, **kwds):
+        try:
+            import pexpect
+        except ImportError, e:
+            py.test.skip(str(e))
+        kwds.setdefault('timeout', 10)
+        child = pexpect.spawn(*args, **kwds)
+        child.logfile = sys.stdout
+        return child
+
+    def spawn(self, argv=[]):
+        # avoid running start.py, cause it might contain
+        # things like readline or rlcompleter(2) included
+        child = self._spawn(sys.executable, ['-S'] + argv)
+        child.sendline('from pyrepl.python_reader import main')
+        child.sendline('main()')
+        return child
+
+    def test_basic(self):
+        child = self.spawn()
+        child.sendline('a = 3')
+        child.sendline('a')
+        child.expect('3')
+        

pypy/module/test_lib_pypy/pyrepl/test_wishes.py

+#   Copyright 2000-2004 Michael Hudson-Doyle <micahel@gmail.com>
+#
+#                        All Rights Reserved
+#
+#
+# Permission to use, copy, modify, and distribute this software and
+# its documentation for any purpose is hereby granted without fee,
+# provided that the above copyright notice appear in all copies and
+# that both that copyright notice and this permission notice appear in
+# supporting documentation.
+#
+# THE AUTHOR MICHAEL HUDSON DISCLAIMS ALL WARRANTIES WITH REGARD TO
+# THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+# AND FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL,
+# INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+# RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+# CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+from pyrepl.console import Event
+from pyrepl.tests.infrastructure import ReaderTestCase, EA, run_testcase
+
+# this test case should contain as-verbatim-as-possible versions of
+# (applicable) feature requests
+
+class WishesTestCase(ReaderTestCase):
+
+    def test_quoted_insert_repeat(self):
+        self.run_test([(('digit-arg', '3'),      ['']),
+                       ( 'quoted-insert',        ['']),
+                       (('self-insert', '\033'), ['^[^[^[']),
+                       ( 'accept',               None)])
+
+def test():
+    run_testcase(WishesTestCase)
+
+if __name__ == '__main__':
+    test()