From 961270022d85aa827e5facc9ec8a41154e50a428 Mon Sep 17 00:00:00 2001 From: Dylan Hurd Date: Wed, 17 Dec 2025 17:12:14 -0800 Subject: [PATCH] detach unit tests from scenarios --- codex-rs/apply-patch/src/lib.rs | 44 +++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/codex-rs/apply-patch/src/lib.rs b/codex-rs/apply-patch/src/lib.rs index 46731f04c8..7a1621cf44 100644 --- a/codex-rs/apply-patch/src/lib.rs +++ b/codex-rs/apply-patch/src/lib.rs @@ -831,13 +831,22 @@ mod tests { fn test_apply_patch_multiple_change_contexts_success() { let dir = tempdir().unwrap(); let path = dir.path().join("example.py"); - let original = - include_str!("../tests/fixtures/scenarios/019_multiple_context_lines/input/example.py"); + let original = r#" +class BaseClass: + def method(): + # untouched + pass + +class OtherClass: + def method(): + # to_remove + pass +"#; fs::write(&path, original).unwrap(); let patch = wrap_patch(&format!( r#"*** Update File: {} -@@ class BaseClass: +@@ class OtherClass: @@ def method(): - # to_remove + # to_add"#, @@ -849,9 +858,17 @@ mod tests { apply_patch(&patch, &mut stdout, &mut stderr).unwrap(); let contents = fs::read_to_string(&path).unwrap(); - let expected = include_str!( - "../tests/fixtures/scenarios/019_multiple_context_lines/expected/example.py" - ); + let expected = r#" +class BaseClass: + def method(): + # untouched + pass + +class OtherClass: + def method(): + # to_add + pass +"#; assert_eq!(contents, expected); } @@ -1098,8 +1115,15 @@ g fn test_apply_patch_multiple_change_contexts_missing_context() { let dir = tempdir().unwrap(); let path = dir.path().join("example.py"); - let original = - include_str!("../tests/fixtures/scenarios/019_multiple_context_lines/input/example.py"); + let original = r#"class BaseClass: + def method(): + # to_remove + pass + +class OtherClass: + def method(): + # untouched + pass"#; fs::write(&path, original).unwrap(); let patch = wrap_patch(&format!( @@ -1115,11 +1139,11 @@ g let mut stderr = Vec::new(); let result = apply_patch(&patch, &mut stdout, &mut stderr); - assert_matches!( + assert!(matches!( result, Err(ApplyPatchError::IoError(IoError { context, .. })) if context.contains("Failed to find context ' def missing():'") && context.contains(&path.display().to_string()) - ); + )); } }