File tree Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ :data: `sys.stdin ` now contains all expected methods of a file-like object when capture is enabled.
Original file line number Diff line number Diff line change @@ -203,12 +203,39 @@ def __iter__(self):
203
203
def fileno (self ) -> int :
204
204
raise UnsupportedOperation ("redirected stdin is pseudofile, has no fileno()" )
205
205
206
+ def flush (self ) -> None :
207
+ raise UnsupportedOperation ("redirected stdin is pseudofile, has no flush()" )
208
+
206
209
def isatty (self ) -> bool :
207
210
return False
208
211
209
212
def close (self ) -> None :
210
213
pass
211
214
215
+ def readable (self ) -> bool :
216
+ return False
217
+
218
+ def seek (self , offset : int ) -> int :
219
+ raise UnsupportedOperation ("redirected stdin is pseudofile, has no seek(int)" )
220
+
221
+ def seekable (self ) -> bool :
222
+ return False
223
+
224
+ def tell (self ) -> int :
225
+ raise UnsupportedOperation ("redirected stdin is pseudofile, has no tell()" )
226
+
227
+ def truncate (self , size : int ) -> None :
228
+ raise UnsupportedOperation ("cannont truncate stdin" )
229
+
230
+ def write (self , * args ) -> None :
231
+ raise UnsupportedOperation ("cannot write to stdin" )
232
+
233
+ def writelines (self , * args ) -> None :
234
+ raise UnsupportedOperation ("Cannot write to stdin" )
235
+
236
+ def writable (self ) -> bool :
237
+ return False
238
+
212
239
@property
213
240
def buffer (self ):
214
241
return self
Original file line number Diff line number Diff line change @@ -897,6 +897,15 @@ def test_dontreadfrominput() -> None:
897
897
iter_f = iter (f )
898
898
pytest .raises (OSError , next , iter_f )
899
899
pytest .raises (UnsupportedOperation , f .fileno )
900
+ pytest .raises (UnsupportedOperation , f .flush )
901
+ assert not f .readable ()
902
+ pytest .raises (UnsupportedOperation , f .seek , 0 )
903
+ assert not f .seekable ()
904
+ pytest .raises (UnsupportedOperation , f .tell )
905
+ pytest .raises (UnsupportedOperation , f .truncate , 0 )
906
+ pytest .raises (UnsupportedOperation , f .write , b"" )
907
+ pytest .raises (UnsupportedOperation , f .writelines , [])
908
+ assert not f .writable ()
900
909
f .close () # just for completeness
901
910
902
911
You can’t perform that action at this time.
0 commit comments