@@ -831,13 +831,22 @@ mod tests {
831831 fn test_apply_patch_multiple_change_contexts_success ( ) {
832832 let dir = tempdir ( ) . unwrap ( ) ;
833833 let path = dir. path ( ) . join ( "example.py" ) ;
834- let original =
835- include_str ! ( "../tests/fixtures/scenarios/019_multiple_context_lines/input/example.py" ) ;
834+ let original = r#"
835+ class BaseClass:
836+ def method():
837+ # untouched
838+ pass
839+
840+ class OtherClass:
841+ def method():
842+ # to_remove
843+ pass
844+ "# ;
836845 fs:: write ( & path, original) . unwrap ( ) ;
837846
838847 let patch = wrap_patch ( & format ! (
839848 r#"*** Update File: {}
840- @@ class BaseClass :
849+ @@ class OtherClass :
841850@@ def method():
842851- # to_remove
843852+ # to_add"# ,
@@ -849,9 +858,17 @@ mod tests {
849858 apply_patch ( & patch, & mut stdout, & mut stderr) . unwrap ( ) ;
850859
851860 let contents = fs:: read_to_string ( & path) . unwrap ( ) ;
852- let expected = include_str ! (
853- "../tests/fixtures/scenarios/019_multiple_context_lines/expected/example.py"
854- ) ;
861+ let expected = r#"
862+ class BaseClass:
863+ def method():
864+ # untouched
865+ pass
866+
867+ class OtherClass:
868+ def method():
869+ # to_add
870+ pass
871+ "# ;
855872 assert_eq ! ( contents, expected) ;
856873 }
857874
10981115 fn test_apply_patch_multiple_change_contexts_missing_context ( ) {
10991116 let dir = tempdir ( ) . unwrap ( ) ;
11001117 let path = dir. path ( ) . join ( "example.py" ) ;
1101- let original =
1102- include_str ! ( "../tests/fixtures/scenarios/019_multiple_context_lines/input/example.py" ) ;
1118+ let original = r#"class BaseClass:
1119+ def method():
1120+ # to_remove
1121+ pass
1122+
1123+ class OtherClass:
1124+ def method():
1125+ # untouched
1126+ pass"# ;
11031127 fs:: write ( & path, original) . unwrap ( ) ;
11041128
11051129 let patch = wrap_patch ( & format ! (
@@ -1115,11 +1139,11 @@ g
11151139 let mut stderr = Vec :: new ( ) ;
11161140 let result = apply_patch ( & patch, & mut stdout, & mut stderr) ;
11171141
1118- assert_matches ! (
1142+ assert ! ( matches !(
11191143 result,
11201144 Err ( ApplyPatchError :: IoError ( IoError { context, .. } ) )
11211145 if context. contains( "Failed to find context ' def missing():'" )
11221146 && context. contains( & path. display( ) . to_string( ) )
1123- ) ;
1147+ ) ) ;
11241148 }
11251149}
0 commit comments