@@ -29,26 +29,12 @@ def test_load_config_with_path_hint(self):
2929 os .unlink (f .name )
3030
3131 def test_load_config_with_nonexistent_path_hint (self ):
32- """Test loading config when path hint doesn't exist, falls back to default paths."""
33- # Create a temporary cchk.toml in current directory
34- config_content = b"""
35- [checks]
36- fallback = true
37- """
38- original_cwd = os .getcwd ()
39- with tempfile .TemporaryDirectory () as tmpdir :
40- os .chdir (tmpdir )
41- try :
42- # Create cchk.toml in temp directory
43- with open ("cchk.toml" , "wb" ) as f :
44- f .write (config_content )
45-
46- # Try to load with nonexistent path hint
47- config = load_config ("nonexistent.toml" )
48- assert "checks" in config
49- assert config ["checks" ]["fallback" ] is True
50- finally :
51- os .chdir (original_cwd )
32+ """Test loading config when path hint doesn't exist - should raise FileNotFoundError."""
33+ # Test that specifying a nonexistent config file raises an error
34+ with pytest .raises (
35+ FileNotFoundError , match = "Specified config file not found: nonexistent.toml"
36+ ):
37+ load_config ("nonexistent.toml" )
5238
5339 def test_load_config_default_cchk_toml (self ):
5440 """Test loading config from default cchk.toml path."""
@@ -89,23 +75,27 @@ def test_load_config_default_commit_check_toml(self):
8975 os .chdir (original_cwd )
9076
9177 def test_load_config_file_not_found (self ):
92- """Test FileNotFoundError when no config files exist."""
78+ """Test returning empty config when no default config files exist."""
9379 original_cwd = os .getcwd ()
9480 with tempfile .TemporaryDirectory () as tmpdir :
9581 os .chdir (tmpdir )
9682 try :
97- with pytest .raises (FileNotFoundError , match = "No config file found" ):
98- load_config ()
83+ # Should return empty config when no default files exist
84+ config = load_config ()
85+ assert config == {}
9986 finally :
10087 os .chdir (original_cwd )
10188
10289 def test_load_config_file_not_found_with_invalid_path_hint (self ):
103- """Test FileNotFoundError when path hint and default paths don 't exist."""
90+ """Test FileNotFoundError when specified path hint doesn 't exist."""
10491 original_cwd = os .getcwd ()
10592 with tempfile .TemporaryDirectory () as tmpdir :
10693 os .chdir (tmpdir )
10794 try :
108- with pytest .raises (FileNotFoundError , match = "No config file found" ):
95+ with pytest .raises (
96+ FileNotFoundError ,
97+ match = "Specified config file not found: nonexistent.toml" ,
98+ ):
10999 load_config ("nonexistent.toml" )
110100 finally :
111101 os .chdir (original_cwd )
0 commit comments