@@ -37,7 +37,7 @@ def test_save_as(self):
37
37
common .walk_aaf (f .root )
38
38
39
39
def test_exit_with_exception_no_save (self ):
40
- new_file = os .path .join (common .sandbox (), 'save_with_exception_no_save .aaf' )
40
+ new_file = os .path .join (common .sandbox (), 'test_exit_with_exception_no_save .aaf' )
41
41
test_file = common .test_file_01 ()
42
42
shutil .copy (test_file , new_file )
43
43
@@ -64,7 +64,7 @@ def test_exit_with_exception_no_save(self):
64
64
65
65
def test_exit_with_exception_with_save (self ):
66
66
67
- new_file = os .path .join (common .sandbox (), 'save_with_exception_with_save .aaf' )
67
+ new_file = os .path .join (common .sandbox (), 'test_exit_with_exception_with_save .aaf' )
68
68
test_file = common .test_file_01 ()
69
69
shutil .copy (test_file , new_file )
70
70
@@ -97,7 +97,7 @@ def test_exit_with_internal_exception(self):
97
97
an exception occurs during the exit phase of the context manager.
98
98
"""
99
99
100
- new_file = os .path .join (common .sandbox (), 'save_with_exception_with_save .aaf' )
100
+ new_file = os .path .join (common .sandbox (), 'test_exit_with_internal_exception .aaf' )
101
101
test_file = common .test_file_01 ()
102
102
shutil .copy (test_file , new_file )
103
103
@@ -132,7 +132,7 @@ def test_exit_with_internal_and_external_exception(self):
132
132
# Exception occurs in with block and also in the except clause
133
133
# while closing file descriptors.
134
134
135
- new_file = os .path .join (common .sandbox (), 'save_with_exception_with_save .aaf' )
135
+ new_file = os .path .join (common .sandbox (), 'test_exit_with_internal_and_external_exception .aaf' )
136
136
test_file = common .test_file_01 ()
137
137
shutil .copy (test_file , new_file )
138
138
@@ -167,6 +167,20 @@ def mock(*args, **kwargs):
167
167
with aaf2 .open (new_file , 'r' ) as f :
168
168
pass
169
169
170
+ def test_raise_on_close_in_except (self ):
171
+ # Test that AAFFile.f.close exceptions are propagated to
172
+ # the user's code.
173
+ with self .assertRaises (RuntimeError ):
174
+ with aaf2 .open () as fd :
175
+ def mock (* args , ** kwargs ):
176
+ raise RuntimeError ('asd' )
177
+
178
+ originalClose = fd .f .close
179
+ fd .f .close = mock
180
+ raise ValueError ('asd' )
181
+
182
+ originalClose ()
183
+
170
184
def test_save_after_close (self ):
171
185
aaf_file = aaf2 .open ()
172
186
aaf_file .close ()
0 commit comments