File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed
clang/bindings/python/tests/cindex Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -21,13 +21,16 @@ def test_create_fail(self):
2121
2222 # clang_CompilationDatabase_fromDirectory calls fprintf(stderr, ...)
2323 # Suppress its output.
24- stderr = os .dup (2 )
25- with open (os .devnull , "wb" ) as null :
26- os .dup2 (null .fileno (), 2 )
27- with self .assertRaises (CompilationDatabaseError ) as cm :
28- CompilationDatabase .fromDirectory (path )
29- os .dup2 (stderr , 2 )
30- os .close (stderr )
24+ try :
25+ stderr = os .dup (2 )
26+ with open (os .devnull , "wb" ) as null :
27+ os .dup2 (null .fileno (), 2 )
28+ with self .assertRaises (CompilationDatabaseError ) as cm :
29+ CompilationDatabase .fromDirectory (path )
30+ # Ensures that stderr is reset even if the above code crashes
31+ finally :
32+ os .dup2 (stderr , 2 )
33+ os .close (stderr )
3134
3235 e = cm .exception
3336 self .assertEqual (e .cdb_error , CompilationDatabaseError .ERROR_CANNOTLOADDATABASE )
You can’t perform that action at this time.
0 commit comments