Commit 2b457640 authored by Kirill Smelkov's avatar Kirill Smelkov

*/tests: Use defer instead of finally

try/finally was used in a couple of places to save/restore default ZBlk
format setting. Move the restore part close to save with the help of
defer.
parent 5c8340d2
......@@ -730,8 +730,10 @@ def test_bigfile_filezodb_fmt_change():
# save/restore original ZBlk_fmt_write
fmt_write_save = file_zodb.ZBlk_fmt_write
def _():
file_zodb.ZBlk_fmt_write = fmt_write_save
defer(_)
try:
# check all combinations of format pairs via working with blk #0 and
# checking internal f structure
for src_fmt, src_type in ZBlk_fmt_registry.items():
......@@ -751,22 +753,17 @@ def test_bigfile_filezodb_fmt_change():
assert type(f.blktab[0]) is dst_type
finally:
file_zodb.ZBlk_fmt_write = fmt_write_save
# test that ZData are reused for changed chunks in ZBlk1 format
@func
def test_bigfile_zblk1_zdata_reuse():
# set ZBlk_fmt_write to ZBlk1 for this test
fmt_write_save = file_zodb.ZBlk_fmt_write
file_zodb.ZBlk_fmt_write = 'ZBlk1'
try:
_test_bigfile_zblk1_zdata_reuse()
finally:
def _():
file_zodb.ZBlk_fmt_write = fmt_write_save
defer(_)
@func
def _test_bigfile_zblk1_zdata_reuse():
root = dbopen()
defer(lambda: dbclose(root))
root['zfile6'] = f = ZBigFile(blksize)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment