From d4b15b33766eea01e067e2d90fb35e078307b216 Mon Sep 17 00:00:00 2001 From: Akash Verma Date: Wed, 30 Oct 2024 16:40:59 -0700 Subject: [PATCH] Update profiling to work with python3.12 --- openhtf/core/test_descriptor.py | 2 +- openhtf/core/test_executor.py | 11 +++++------ openhtf/util/test.py | 2 +- test/core/exe_test.py | 32 ++++++++++++++++---------------- 4 files changed, 23 insertions(+), 24 deletions(-) diff --git a/openhtf/core/test_descriptor.py b/openhtf/core/test_descriptor.py index 9e0d383e..a017643c 100644 --- a/openhtf/core/test_descriptor.py +++ b/openhtf/core/test_descriptor.py @@ -329,7 +329,7 @@ def trigger_phase(test): self.make_uid(), trigger, self._test_options, - run_with_profiling=profile_filename is not None) + run_phases_with_profiling=profile_filename is not None) _LOG.info('Executing test: %s', self.descriptor.code_info.name) self.TEST_INSTANCES[self.uid] = self diff --git a/openhtf/core/test_executor.py b/openhtf/core/test_executor.py index 8b9f80c5..634af20d 100644 --- a/openhtf/core/test_executor.py +++ b/openhtf/core/test_executor.py @@ -96,11 +96,10 @@ def __init__(self, test_descriptor: 'test_descriptor.TestDescriptor', execution_uid: Text, test_start: Optional[phase_descriptor.PhaseDescriptor], test_options: 'test_descriptor.TestOptions', - run_with_profiling: bool): - super(TestExecutor, self).__init__( - name='TestExecutorThread', run_with_profiling=run_with_profiling) + run_phases_with_profiling: bool): + super(TestExecutor, self).__init__(name='TestExecutorThread') self.test_state = None # type: Optional[test_state.TestState] - + self._run_phases_with_profiling = run_phases_with_profiling self._test_descriptor = test_descriptor self._test_start = test_start self._test_options = test_options @@ -276,7 +275,7 @@ def _execute_test_start(self) -> bool: return True outcome, profile_stats = self.phase_executor.execute_phase( - self._test_start, self._run_with_profiling + self._test_start, self._run_phases_with_profiling ) if profile_stats is not None: @@ -339,7 +338,7 @@ def _execute_phase(self, phase: phase_descriptor.PhaseDescriptor, outcome, profile_stats = self.phase_executor.execute_phase( phase, - run_with_profiling=self._run_with_profiling, + run_with_profiling=self._run_phases_with_profiling, subtest_rec=subtest_rec, ) if profile_stats is not None: diff --git a/openhtf/util/test.py b/openhtf/util/test.py index 2c794011..1d9d8835 100644 --- a/openhtf/util/test.py +++ b/openhtf/util/test.py @@ -439,7 +439,7 @@ def _handle_test(self, test): if profile_filepath is None: profile_tempfile = None else: - profile_tempfile = tempfile.NamedTemporaryFile() + profile_tempfile = tempfile.NamedTemporaryFile(delete=False) # Mock the PlugManager to use ours instead, and execute the test. with mock.patch.object( plugs, 'PlugManager', new=lambda _, __: self.plug_manager): diff --git a/test/core/exe_test.py b/test/core/exe_test.py index 406afcff..d05f8d0d 100644 --- a/test/core/exe_test.py +++ b/test/core/exe_test.py @@ -258,7 +258,7 @@ def set_ev(): 'uid', start_phase, test._test_options, - run_with_profiling=False) + run_phases_with_profiling=False) executor.start() executor.wait() @@ -273,7 +273,7 @@ def set_ev(): 'uid', start_phase, test._test_options, - run_with_profiling=False) + run_phases_with_profiling=False) executor.start() executor.wait() record = executor.running_test_state.test_record @@ -331,7 +331,7 @@ def set_ev(): 'uid', cancel_phase, test._test_options, - run_with_profiling=False) + run_phases_with_profiling=False) executor.start() executor.wait() @@ -366,7 +366,7 @@ def set_ev(): 'uid', start_phase, test._test_options, - run_with_profiling=False) + run_phases_with_profiling=False) executor.start() executor.wait() @@ -408,7 +408,7 @@ def set_ev(): 'uid', start_phase, test._test_options, - run_with_profiling=False) + run_phases_with_profiling=False) executor.start() executor.wait() @@ -459,7 +459,7 @@ def teardown2_phase(): 'uid', start_phase, test._test_options, - run_with_profiling=False) + run_phases_with_profiling=False) executor.start() executor.wait() @@ -488,7 +488,7 @@ def set_ev(): 'uid', None, test._test_options, - run_with_profiling=False) + run_phases_with_profiling=False) executor.start() executor.wait() record = executor.running_test_state.test_record @@ -522,7 +522,7 @@ def set_ev(): 'uid', fail_plug_phase, test._test_options, - run_with_profiling=False) + run_phases_with_profiling=False) executor.start() executor.wait() record = executor.running_test_state.test_record @@ -544,7 +544,7 @@ def test_error_during_teardown(self): 'uid', start_phase, test._test_options, - run_with_profiling=False) + run_phases_with_profiling=False) executor.start() executor.wait() record = executor.running_test_state.test_record @@ -568,7 +568,7 @@ def teardown_log(test): 'uid', start_phase, test._test_options, - run_with_profiling=False) + run_phases_with_profiling=False) executor.start() executor.wait() record = executor.running_test_state.test_record @@ -596,7 +596,7 @@ def set_ev(): 'uid', start_phase, test._test_options, - run_with_profiling=False) + run_phases_with_profiling=False) executor.start() executor.wait() @@ -628,7 +628,7 @@ def set_ev(): 'uid', start_phase, test._test_options, - run_with_profiling=False) + run_phases_with_profiling=False) executor.start() executor.wait() @@ -665,7 +665,7 @@ def setUp(self): td.uid, None, test_descriptor.TestOptions(), - run_with_profiling=False) + run_phases_with_profiling=False) self.test_exec.test_state = self.test_state self.test_exec._phase_exec = self.phase_exec @@ -742,7 +742,7 @@ def setUp(self): td.uid, None, test_descriptor.TestOptions(), - run_with_profiling=False) + run_phases_with_profiling=False) self.test_exec.test_state = self.test_state patcher = mock.patch.object(self.test_exec, '_execute_node') self.mock_execute_node = patcher.start() @@ -897,7 +897,7 @@ def setUp(self): td.uid, None, test_descriptor.TestOptions(), - run_with_profiling=False) + run_phases_with_profiling=False) self.test_exec.test_state = self.test_state patcher = mock.patch.object(self.test_exec, '_execute_sequence') self.mock_execute_sequence = patcher.start() @@ -1086,7 +1086,7 @@ def setUp(self): td.uid, None, test_descriptor.TestOptions(), - run_with_profiling=False) + run_phases_with_profiling=False) self.test_exec.test_state = self.test_state patcher = mock.patch.object(self.test_exec, '_execute_sequence') self.mock_execute_sequence = patcher.start()