Commits

Brian Kearns committed 4cc8525

apply some fixes to get the pyrepl tests running

Comments (0)

Files changed (4)

lib_pypy/pyrepl/reader.py

             if not event: # can only happen if we're not blocking
                 return None
 
+            translate = True
+
             if event.evt == 'key':
                 self.input_trans.push(event)
             elif event.evt == 'scroll':
             elif event.evt == 'resize':
                 self.refresh()
             else:
-                pass
+                translate = False
 
-            cmd = self.input_trans.get()
+            if translate:
+                cmd = self.input_trans.get()
+            else:
+                cmd = event.evt, event.data
 
             if cmd is None:
                 if block:

lib_pypy/pyrepl/readline.py

 # ____________________________________________________________
 
 class _ReadlineWrapper(object):
-    f_in = 0
-    f_out = 1
     reader = None
     saved_history_length = -1
     startup_hook = None
     config = ReadlineConfig()
 
+    def __init__(self, f_in=None, f_out=None):
+        self.f_in = f_in if f_in is not None else os.dup(0)
+        self.f_out = f_out if f_out is not None else os.dup(1)
+
     def get_reader(self):
         if self.reader is None:
             console = UnixConsole(self.f_in, self.f_out, encoding=ENCODING)

pypy/module/test_lib_pypy/pyrepl/infrastructure.py

         return Event(*ev)
 
 
-class TestReader(Reader):
+class BaseTestReader(Reader):
 
     def get_prompt(self, lineno, cursor_on_line):
         return ''
         self.dirty = True
 
 
-def read_spec(test_spec, reader_class=TestReader):
+def read_spec(test_spec, reader_class=BaseTestReader):
     # remember to finish your test_spec with 'accept' or similar!
     con = TestConsole(test_spec, verbose=True)
     reader = reader_class(con)

pypy/module/test_lib_pypy/pyrepl/test_bugs.py

 # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 from pyrepl.historical_reader import HistoricalReader
-from .infrastructure import EA, TestReader, read_spec
+from .infrastructure import EA, BaseTestReader, read_spec
 
 # this test case should contain as-verbatim-as-possible versions of
 # (applicable) bug reports
 import pytest
 
 
-class HistoricalTestReader(HistoricalReader, TestReader):
+class HistoricalTestReader(HistoricalReader, BaseTestReader):
     pass
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.