@@ -214,14 +214,13 @@ def test_get_processing_dependencies_multiple_lists(self):
214214
215215 assert result == ["dep1" , "dep2" , "dep3" , "dep4" , "dep5" ]
216216
217- def test_get_processing_code_hash_with_none_dependencies (self ):
218- """Test get_processing_code_hash does not raise TypeError when dependencies is None """
217+ def test_get_processing_code_hash_with_none_dependencies_and_code_only (self ):
218+ """Test get_processing_code_hash with None dependencies and code only """
219219 with tempfile .NamedTemporaryFile (mode = "w" , suffix = ".py" , delete = False ) as f :
220220 f .write ("print('hello')" )
221221 temp_file = f .name
222222
223223 try :
224- # Should not raise TypeError
225224 result = get_processing_code_hash (code = temp_file , source_dir = None , dependencies = None )
226225
227226 assert result is not None
@@ -230,12 +229,11 @@ def test_get_processing_code_hash_with_none_dependencies(self):
230229 os .unlink (temp_file )
231230
232231 def test_get_processing_code_hash_with_none_dependencies_and_source_dir (self ):
233- """Test get_processing_code_hash with source_dir and None dependencies"""
232+ """Test get_processing_code_hash with None dependencies and source_dir """
234233 with tempfile .TemporaryDirectory () as temp_dir :
235234 code_file = Path (temp_dir , "script.py" )
236235 code_file .write_text ("print('hello')" )
237236
238- # Should not raise TypeError
239237 result = get_processing_code_hash (
240238 code = str (code_file ), source_dir = temp_dir , dependencies = None
241239 )
@@ -294,12 +292,11 @@ def test_get_processing_code_hash_with_dependencies(self):
294292 assert result is not None
295293
296294 def test_get_training_code_hash_with_none_dependencies_and_source_dir (self ):
297- """Test get_training_code_hash with source_dir and None dependencies does not raise """
295+ """Test get_training_code_hash with None dependencies and source_dir """
298296 with tempfile .TemporaryDirectory () as temp_dir :
299297 entry_file = Path (temp_dir , "train.py" )
300298 entry_file .write_text ("print('training')" )
301299
302- # Should not raise TypeError
303300 result = get_training_code_hash (
304301 entry_point = str (entry_file ), source_dir = temp_dir , dependencies = None
305302 )
@@ -308,18 +305,20 @@ def test_get_training_code_hash_with_none_dependencies_and_source_dir(self):
308305 assert len (result ) == 64
309306
310307 def test_get_training_code_hash_with_none_dependencies_and_entry_point (self ):
311- """Test get_training_code_hash with entry_point only and None dependencies does not raise """
312- with tempfile .TemporaryDirectory ( ) as temp_dir :
313- entry_file = Path ( temp_dir , "train.py " )
314- entry_file . write_text ( "print('training')" )
308+ """Test get_training_code_hash with None dependencies and entry_point only """
309+ with tempfile .NamedTemporaryFile ( mode = "w" , suffix = ".py" , delete = False ) as f :
310+ f . write ( "print('training') " )
311+ temp_file = f . name
315312
316- # Should not raise TypeError
313+ try :
317314 result = get_training_code_hash (
318- entry_point = str ( entry_file ) , source_dir = None , dependencies = None
315+ entry_point = temp_file , source_dir = None , dependencies = None
319316 )
320317
321318 assert result is not None
322319 assert len (result ) == 64
320+ finally :
321+ os .unlink (temp_file )
323322
324323 def test_get_training_code_hash_with_source_dir (self ):
325324 """Test get_training_code_hash with source_dir"""
0 commit comments