@@ -129,8 +129,6 @@ def handleCmd(self, cmd, check=True, collect_result=True):
129
129
130
130
131
131
@add_test_categories (['pyapi' ])
132
- @skipIfWindows # FIXME pre-existing bug, should be fixed
133
- # when we delete the FILE* typemaps.
134
132
def test_legacy_file_out_script (self ):
135
133
with open (self .out_filename , 'w' ) as f :
136
134
self .debugger .SetOutputFileHandle (f , False )
@@ -155,8 +153,6 @@ def test_legacy_file_out(self):
155
153
self .assertIn ('deadbeef' , f .read ())
156
154
157
155
@add_test_categories (['pyapi' ])
158
- @skipIfWindows # FIXME pre-existing bug, should be fixed
159
- # when we delete the FILE* typemaps.
160
156
def test_legacy_file_err_with_get (self ):
161
157
with open (self .out_filename , 'w' ) as f :
162
158
self .debugger .SetErrorFileHandle (f , False )
@@ -194,11 +190,11 @@ def test_legacy_file_error(self):
194
190
@add_test_categories (['pyapi' ])
195
191
def test_sbfile_type_errors (self ):
196
192
sbf = lldb .SBFile ()
197
- self .assertRaises (TypeError , sbf .Write , None )
198
- self .assertRaises (TypeError , sbf .Read , None )
199
- self .assertRaises (TypeError , sbf .Read , b'this bytes is not mutable' )
200
- self .assertRaises (TypeError , sbf .Write , u"ham sandwich" )
201
- self .assertRaises (TypeError , sbf .Read , u"ham sandwich" )
193
+ self .assertRaises (Exception , sbf .Write , None )
194
+ self .assertRaises (Exception , sbf .Read , None )
195
+ self .assertRaises (Exception , sbf .Read , b'this bytes is not mutable' )
196
+ self .assertRaises (Exception , sbf .Write , u"ham sandwich" )
197
+ self .assertRaises (Exception , sbf .Read , u"ham sandwich" )
202
198
203
199
204
200
@add_test_categories (['pyapi' ])
@@ -859,3 +855,40 @@ def i(sbf):
859
855
with open (self .out_filename , 'r' ) as f :
860
856
self .assertEqual (list (range (10 )), list (map (int , f .read ().strip ().split ())))
861
857
858
+
859
+ @add_test_categories (['pyapi' ])
860
+ def test_set_filehandle_none (self ):
861
+ self .assertRaises (Exception , self .debugger .SetOutputFile , None )
862
+ self .assertRaises (Exception , self .debugger .SetOutputFile , "ham sandwich" )
863
+ self .assertRaises (Exception , self .debugger .SetOutputFileHandle , "ham sandwich" )
864
+ self .assertRaises (Exception , self .debugger .SetInputFile , None )
865
+ self .assertRaises (Exception , self .debugger .SetInputFile , "ham sandwich" )
866
+ self .assertRaises (Exception , self .debugger .SetInputFileHandle , "ham sandwich" )
867
+ self .assertRaises (Exception , self .debugger .SetErrorFile , None )
868
+ self .assertRaises (Exception , self .debugger .SetErrorFile , "ham sandwich" )
869
+ self .assertRaises (Exception , self .debugger .SetErrorFileHandle , "ham sandwich" )
870
+
871
+ with open (self .out_filename , 'w' ) as f :
872
+ status = self .debugger .SetOutputFile (f )
873
+ self .assertTrue (status .Success ())
874
+ status = self .debugger .SetErrorFile (f )
875
+ self .assertTrue (status .Success ())
876
+ self .debugger .SetOutputFileHandle (None , False )
877
+ self .debugger .SetErrorFileHandle (None , False )
878
+ sbf = self .debugger .GetOutputFile ()
879
+ if sys .version_info .major >= 3 :
880
+ # python 2 lacks PyFile_FromFd, so GetFile() will
881
+ # have to duplicate the file descriptor and make a FILE*
882
+ # in order to convert a NativeFile it back to a python
883
+ # file.
884
+ self .assertEqual (sbf .GetFile ().fileno (), 1 )
885
+ sbf = self .debugger .GetErrorFile ()
886
+ if sys .version_info .major >= 3 :
887
+ self .assertEqual (sbf .GetFile ().fileno (), 2 )
888
+ with open (self .out_filename , 'r' ) as f :
889
+ status = self .debugger .SetInputFile (f )
890
+ self .assertTrue (status .Success ())
891
+ self .debugger .SetInputFileHandle (None , False )
892
+ sbf = self .debugger .GetInputFile ()
893
+ if sys .version_info .major >= 3 :
894
+ self .assertEqual (sbf .GetFile ().fileno (), 0 )
0 commit comments