@@ -61,8 +61,8 @@ def test_add_side_effects_files(
6161 assert side_effect_file_name in job .packaged_files
6262
6363
64- def test_default_execution_manager_cell_tracking_hook ():
65- """Test that DefaultExecutionManager sets up on_cell_executed hook when track_cell_execution is supported """
64+ def test_default_execution_manager_cell_tracking_hook_not_set_by_default ():
65+ """Test that DefaultExecutionManager does NOT set up on_cell_executed hook when track_cell_execution is disabled by default """
6666 job_id = "test-job-id"
6767
6868 with patch .object (DefaultExecutionManager , "model" ) as mock_model :
@@ -100,9 +100,8 @@ def test_default_execution_manager_cell_tracking_hook():
100100 # Verify ExecutePreprocessor was created
101101 mock_ep_class .assert_called_once ()
102102
103- # Verify on_cell_executed hook was set
104- assert hasattr (mock_ep , "on_cell_executed" )
105- assert mock_ep .on_cell_executed is not None
103+ # Verify patching method was never called
104+ mock_model .__update_completed_cells_hook .assert_not_called ()
106105
107106
108107def test_update_completed_cells_hook ():
@@ -158,8 +157,8 @@ def test_update_completed_cells_hook_database_error():
158157 # Mock db_session with error
159158 mock_db_session = MagicMock ()
160159 mock_session_context = MagicMock ()
161- mock_session_context .query .return_value .filter .return_value .update .side_effect = Exception (
162- "DB Error"
160+ mock_session_context .query .return_value .filter .return_value .update .side_effect = (
161+ Exception ( "DB Error" )
163162 )
164163 mock_db_session .return_value .__enter__ .return_value = mock_session_context
165164 manager ._db_session = mock_db_session
@@ -181,12 +180,18 @@ def test_update_completed_cells_hook_database_error():
181180
182181def test_supported_features_includes_track_cell_execution ():
183182 """Test that DefaultExecutionManager supports track_cell_execution feature"""
184- features = DefaultExecutionManager .supported_features ()
183+ manager = DefaultExecutionManager (
184+ job_id = "test-job-id" ,
185+ root_dir = "/test" ,
186+ db_url = "sqlite:///:memory:" ,
187+ staging_paths = {"input" : "/test/input.ipynb" },
188+ )
189+ features = manager .supported_features ()
185190
186191 from jupyter_scheduler .models import JobFeature
187192
188193 assert JobFeature .track_cell_execution in features
189- assert features [JobFeature .track_cell_execution ] is True
194+ assert features [JobFeature .track_cell_execution ] is False
190195
191196
192197def test_hook_uses_correct_job_id ():
@@ -233,8 +238,7 @@ def test_cell_tracking_disabled_when_feature_false():
233238
234239 # Create a custom execution manager class with track_cell_execution = False
235240 class DisabledTrackingExecutionManager (DefaultExecutionManager ):
236- @classmethod
237- def supported_features (cls ):
241+ def supported_features (self ):
238242 features = super ().supported_features ()
239243 from jupyter_scheduler .models import JobFeature
240244
@@ -256,8 +260,12 @@ def supported_features(cls):
256260 with patch .object (DisabledTrackingExecutionManager , "model" ) as mock_model :
257261 with patch ("jupyter_scheduler.executors.open" , mock = MagicMock ()):
258262 with patch ("jupyter_scheduler.executors.nbformat.read" ) as mock_nb_read :
259- with patch .object (DisabledTrackingExecutionManager , "add_side_effects_files" ):
260- with patch .object (DisabledTrackingExecutionManager , "create_output_files" ):
263+ with patch .object (
264+ DisabledTrackingExecutionManager , "add_side_effects_files"
265+ ):
266+ with patch .object (
267+ DisabledTrackingExecutionManager , "create_output_files"
268+ ):
261269 with patch (
262270 "jupyter_scheduler.executors.ExecutePreprocessor"
263271 ) as mock_ep_class :
@@ -288,15 +296,20 @@ def test_disabled_tracking_feature_support():
288296
289297 # Create a custom execution manager class with track_cell_execution = False
290298 class DisabledTrackingExecutionManager (DefaultExecutionManager ):
291- @classmethod
292- def supported_features (cls ):
299+ def supported_features (self ):
293300 features = super ().supported_features ()
294301 from jupyter_scheduler .models import JobFeature
295302
296303 features [JobFeature .track_cell_execution ] = False
297304 return features
298305
299- features = DisabledTrackingExecutionManager .supported_features ()
306+ manager = DisabledTrackingExecutionManager (
307+ job_id = "test-job-id" ,
308+ root_dir = "/test" ,
309+ db_url = "sqlite:///:memory:" ,
310+ staging_paths = {"input" : "/test/input.ipynb" },
311+ )
312+ features = manager .supported_features ()
300313
301314 from jupyter_scheduler .models import JobFeature
302315
0 commit comments