@@ -349,24 +349,37 @@ def test_multi_line_search_is_found(tmp_path: Path) -> None:
349
349
assert alphabet_path .read_text () == "A\n B\n C\n 10.0.0\n "
350
350
351
351
352
- def test_ignore_missing_version (tmp_path : Path ) -> None :
352
+ @pytest .mark .parametrize (
353
+ ["global_value" , "file_value" , "should_raise" ],
354
+ [
355
+ param (True , True , False , id = "ignore global and file" ),
356
+ param (True , False , True , id = "ignore global only" ),
357
+ param (False , True , False , id = "ignore file only" ),
358
+ param (False , False , True , id = "ignore none" ),
359
+ ],
360
+ )
361
+ def test_ignore_missing_version (global_value : bool , file_value : bool , should_raise : bool , tmp_path : Path ) -> None :
353
362
"""If the version is not found in the file, do nothing."""
354
363
# Arrange
355
364
version_path = tmp_path / Path ("VERSION" )
356
365
version_path .write_text ("1.2.3" )
357
366
358
367
overrides = {
359
368
"current_version" : "1.2.5" ,
360
- "ignore_missing_version" : True ,
361
- "files" : [{"filename" : str (version_path )}],
369
+ "ignore_missing_version" : global_value ,
370
+ "files" : [{"filename" : str (version_path ), "ignore_missing_version" : file_value }],
362
371
}
363
- conf , version_config , current_version = get_config_data (overrides )
364
- assert conf .ignore_missing_version is True
365
- new_version = current_version .bump ("patch" , version_config .order )
366
- cfg_files = [files .ConfiguredFile (file_cfg , version_config ) for file_cfg in conf .files ]
367
-
368
- # Act
369
- files .modify_files (cfg_files , current_version , new_version , get_context (conf ))
372
+ with inside_dir (tmp_path ):
373
+ conf , version_config , current_version = get_config_data (overrides )
374
+ new_version = current_version .bump ("patch" , version_config .order )
375
+ cfg_files = [files .ConfiguredFile (file_cfg , version_config ) for file_cfg in conf .files ]
376
+
377
+ # Act
378
+ if should_raise :
379
+ with pytest .raises (VersionNotFoundError ):
380
+ files .modify_files (cfg_files , current_version , new_version , get_context (conf ))
381
+ else :
382
+ files .modify_files (cfg_files , current_version , new_version , get_context (conf ))
370
383
371
384
# Assert
372
385
assert version_path .read_text () == "1.2.3"
0 commit comments