Skip to content

Commit ee90a08

Browse files
committed
putting file restore in the finally block
1 parent 862eae8 commit ee90a08

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

tests/test_instrument_tests.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -516,12 +516,12 @@ def test_sort():
516516
testing_time=0.1,
517517
line_profiler_output_file = line_profiler_output_file
518518
)
519-
func_optimizer.write_code_and_helpers(
520-
func_optimizer.function_to_optimize_source_code, original_helper_code, func_optimizer.function_to_optimize.file_path
521-
)
522519
tmp_lpr = list(line_profile_results['timings'].keys())
523520
assert len(tmp_lpr) == 1 and line_profile_results['timings'][tmp_lpr[0]][0][1]==2
524521
finally:
522+
func_optimizer.write_code_and_helpers(
523+
func_optimizer.function_to_optimize_source_code, original_helper_code, func_optimizer.function_to_optimize.file_path
524+
)
525525
test_path.unlink(missing_ok=True)
526526
test_path_perf.unlink(missing_ok=True)
527527

@@ -766,12 +766,12 @@ def test_sort_parametrized(input, expected_output):
766766
testing_time=0.1,
767767
line_profiler_output_file = line_profiler_output_file
768768
)
769-
func_optimizer.write_code_and_helpers(
770-
func_optimizer.function_to_optimize_source_code, original_helper_code, func_optimizer.function_to_optimize.file_path
771-
)
772769
tmp_lpr = list(line_profile_results['timings'].keys())
773770
assert len(tmp_lpr) == 1 and line_profile_results['timings'][tmp_lpr[0]][0][1]==3
774771
finally:
772+
func_optimizer.write_code_and_helpers(
773+
func_optimizer.function_to_optimize_source_code, original_helper_code, func_optimizer.function_to_optimize.file_path
774+
)
775775
test_path.unlink(missing_ok=True)
776776
test_path_perf.unlink(missing_ok=True)
777777

@@ -1102,12 +1102,12 @@ def test_sort_parametrized_loop(input, expected_output):
11021102
testing_time=0.1,
11031103
line_profiler_output_file = line_profiler_output_file
11041104
)
1105-
func_optimizer.write_code_and_helpers(
1106-
func_optimizer.function_to_optimize_source_code, original_helper_code, func_optimizer.function_to_optimize.file_path
1107-
)
11081105
tmp_lpr = list(line_profile_results['timings'].keys())
11091106
assert len(tmp_lpr) == 1 and line_profile_results['timings'][tmp_lpr[0]][0][1]==6
11101107
finally:
1108+
func_optimizer.write_code_and_helpers(
1109+
func_optimizer.function_to_optimize_source_code, original_helper_code, func_optimizer.function_to_optimize.file_path
1110+
)
11111111
test_path.unlink(missing_ok=True)
11121112
test_path_behavior.unlink(missing_ok=True)
11131113
test_path_perf.unlink(missing_ok=True)
@@ -1372,12 +1372,12 @@ def test_sort():
13721372
testing_time=0.1,
13731373
line_profiler_output_file = line_profiler_output_file
13741374
)
1375-
func_optimizer.write_code_and_helpers(
1376-
func_optimizer.function_to_optimize_source_code, original_helper_code, func_optimizer.function_to_optimize.file_path
1377-
)
13781375
tmp_lpr = list(line_profile_results['timings'].keys())
13791376
assert len(tmp_lpr) == 1 and line_profile_results['timings'][tmp_lpr[0]][0][1]==3
13801377
finally:
1378+
func_optimizer.write_code_and_helpers(
1379+
func_optimizer.function_to_optimize_source_code, original_helper_code, func_optimizer.function_to_optimize.file_path
1380+
)
13811381
test_path.unlink(missing_ok=True)
13821382
test_path_perf.unlink(missing_ok=True)
13831383
test_path_behavior.unlink(missing_ok=True)

0 commit comments

Comments
 (0)