Skip to content

Commit 032d4d0

Browse files
Add additional test
1 parent 9722f4c commit 032d4d0

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

tests/test_aaf.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def test_save_as(self):
3737
common.walk_aaf(f.root)
3838

3939
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')
4141
test_file = common.test_file_01()
4242
shutil.copy(test_file, new_file)
4343

@@ -64,7 +64,7 @@ def test_exit_with_exception_no_save(self):
6464

6565
def test_exit_with_exception_with_save(self):
6666

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')
6868
test_file = common.test_file_01()
6969
shutil.copy(test_file, new_file)
7070

@@ -97,7 +97,7 @@ def test_exit_with_internal_exception(self):
9797
an exception occurs during the exit phase of the context manager.
9898
"""
9999

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')
101101
test_file = common.test_file_01()
102102
shutil.copy(test_file, new_file)
103103

@@ -132,7 +132,7 @@ def test_exit_with_internal_and_external_exception(self):
132132
# Exception occurs in with block and also in the except clause
133133
# while closing file descriptors.
134134

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')
136136
test_file = common.test_file_01()
137137
shutil.copy(test_file, new_file)
138138

@@ -167,6 +167,20 @@ def mock(*args, **kwargs):
167167
with aaf2.open(new_file, 'r') as f:
168168
pass
169169

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+
170184
def test_save_after_close(self):
171185
aaf_file = aaf2.open()
172186
aaf_file.close()

0 commit comments

Comments
 (0)