Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c816865

Browse filesBrowse files
add more methods to fake stdin/err/out
1 parent d796bca commit c816865
Copy full SHA for c816865

2 files changed

+28Lines changed: 28 additions & 0 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎bpython/curtsiesfrontend/coderunner.py‎

Copy file name to clipboardExpand all lines: bpython/curtsiesfrontend/coderunner.py
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,13 @@ def __init__(self, coderunner, please):
115115
def write(self, *args, **kwargs):
116116
self.please(*args, **kwargs)
117117
return self.coderunner.refresh_and_get_value()
118+
def writelines(self, l):
119+
for s in l:
120+
self.write(s)
121+
def flush(self):
122+
pass
123+
def isatty(self):
124+
return True
118125

119126
def test_simple():
120127
orig_stdout = sys.stdout
Collapse file

‎bpython/curtsiesfrontend/repl.py‎

Copy file name to clipboardExpand all lines: bpython/curtsiesfrontend/repl.py
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import greenlet
88
import subprocess
99
import tempfile
10+
import errno
1011

1112
from bpython.autocomplete import Autocomplete, SIMPLE
1213
from bpython.repl import Repl as BpythonRepl
@@ -90,6 +91,26 @@ def readline(self):
9091
self.readline_results.append(value)
9192
return value
9293

94+
def readlines(self, size=-1):
95+
return list(iter(self.readline, ''))
96+
97+
def __iter__(self):
98+
return iter(self.readlines())
99+
100+
def isatty(self):
101+
return True
102+
103+
def flush(self):
104+
"""Flush the internal buffer. This is a no-op. Flushing stdin
105+
doesn't make any sense anyway."""
106+
107+
def write(self, value):
108+
# XXX IPython expects sys.stdin.write to exist, there will no doubt be
109+
# others, so here's a hack to keep them happy
110+
raise IOError(errno.EBADF, "sys.stdin is read-only")
111+
112+
#TODO write a read() method
113+
93114
class ReevaluateFakeStdin(object):
94115
def __init__(self, fakestdin, repl):
95116
self.fakestdin = fakestdin

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.