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):
21
21
22
22
# clang_CompilationDatabase_fromDirectory calls fprintf(stderr, ...)
23
23
# 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 )
31
34
32
35
e = cm .exception
33
36
self .assertEqual (e .cdb_error , CompilationDatabaseError .ERROR_CANNOTLOADDATABASE )
You can’t perform that action at this time.
0 commit comments