@@ -292,23 +292,43 @@ def test_read_file_raises_for_nonexistent_file(workspace):
292292 workspace .read_file ("/test.txt" )
293293
294294
295- def test_write_file (workspace ):
295+ def test_write_file_basic (workspace ):
296296 file_path = workspace .working_dir / "test.txt"
297297 file_content = "Hello, DebugGym!\n \n \n "
298298 workspace .write_file ("test.txt" , file_content )
299299 assert file_path .read_text () == file_content
300300
301- # Test with single line, no newline at the end.
301+
302+ def test_write_file_single_line_no_newline (workspace ):
303+ file_path = workspace .working_dir / "test.txt"
302304 file_content_single_line = "Hello, DebugGym!"
303305 workspace .write_file ("test.txt" , file_content_single_line )
304306 assert file_path .read_text () == file_content_single_line
305307
306- # Should still work if the content ends with the delimiter.
308+
309+ def test_write_file_with_delimiter (workspace ):
310+ file_path = workspace .working_dir / "test.txt"
307311 file_content_single_line = "Hello, DebugGym!nDEBUGGYM_DEL"
308312 workspace .write_file ("test.txt" , file_content_single_line )
309313 assert file_path .read_text () == file_content_single_line
310314
311- # Test with newlines
315+
316+ def test_write_file_with_newlines (workspace ):
317+ file_path = workspace .working_dir / "test.txt"
312318 file_content_with_newlines = "Hello, DebugGym!\n This is a test.\n "
313319 workspace .write_file ("test.txt" , file_content_with_newlines )
314320 assert file_path .read_text () == file_content_with_newlines
321+
322+
323+ def test_write_file_empty_content (workspace ):
324+ file_path = workspace .working_dir / "test.txt"
325+ file_content_empty = ""
326+ workspace .write_file ("test.txt" , file_content_empty )
327+ assert file_path .read_text () == file_content_empty
328+
329+
330+ def test_write_file_exceeding_max_command_length (workspace ):
331+ file_path = workspace .working_dir / "test.txt"
332+ file_content_exceeding_max_command_length = "A" * (2 * 1024 ** 2 ) # 2MB of 'A's
333+ workspace .write_file ("test.txt" , file_content_exceeding_max_command_length )
334+ assert file_path .read_text () == file_content_exceeding_max_command_length
0 commit comments