@@ -18,10 +18,9 @@ def test_init(self):
1818 def test_init_unsupported_settings_fails_gracefully (self ):
1919 with pytest .raises (exceptions .UnsupportedSettings ):
2020 Config (apply = True )
21- try :
21+ with pytest . raises ( exceptions . UnsupportedSettings ) as error :
2222 Config (apply = True )
23- except exceptions .UnsupportedSettings as error :
24- assert error .unsupported_settings == {"apply" : {"value" : True , "source" : "runtime" }}
23+ assert error .value .unsupported_settings == {"apply" : {"value" : True , "source" : "runtime" }}
2524
2625 def test_known_settings (self ):
2726 assert Config (known_third_party = ["one" ]).known_third_party == frozenset ({"one" })
@@ -35,7 +34,7 @@ def test_invalid_settings_path(self):
3534 Config (settings_path = "this_couldnt_possibly_actually_exists/could_it" )
3635
3736 def test_invalid_pyversion (self ):
38- with pytest .raises (ValueError ):
37+ with pytest .raises (ValueError , match = "The python version 10 is not supported." ):
3938 Config (py_version = 10 )
4039
4140 def test_invalid_profile (self ):
@@ -222,11 +221,11 @@ def test_as_bool():
222221 assert settings ._as_bool ("FALSE" ) is False
223222 assert settings ._as_bool ("faLSE" ) is False
224223 assert settings ._as_bool ("f" ) is False
225- with pytest .raises (ValueError ):
224+ with pytest .raises (ValueError , match = "invalid truth value" ):
226225 settings ._as_bool ("" )
227- with pytest .raises (ValueError ):
226+ with pytest .raises (ValueError , match = "invalid truth value falsey" ):
228227 settings ._as_bool ("falsey" )
229- with pytest .raises (ValueError ):
228+ with pytest .raises (ValueError , match = "invalid truth value truthy" ):
230229 settings ._as_bool ("truthy" )
231230
232231
@@ -277,15 +276,18 @@ def test_find_all_configs(tmpdir):
277276
278277 config_info_1 = config_trie .search (str (dir1 / "test1.py" ))
279278 assert config_info_1 [0 ] == str (setup_cfg_file )
280- assert config_info_1 [0 ] == str (setup_cfg_file ) and config_info_1 [1 ]["profile" ] == "django"
279+ assert config_info_1 [0 ] == str (setup_cfg_file )
280+ assert config_info_1 [1 ]["profile" ] == "django"
281281
282282 config_info_2 = config_trie .search (str (dir2 / "test2.py" ))
283283 assert config_info_2 [0 ] == str (pyproject_toml_file )
284- assert config_info_2 [0 ] == str (pyproject_toml_file ) and config_info_2 [1 ]["profile" ] == "hug"
284+ assert config_info_2 [0 ] == str (pyproject_toml_file )
285+ assert config_info_2 [1 ]["profile" ] == "hug"
285286
286287 config_info_3 = config_trie .search (str (dir3 / "test3.py" ))
287288 assert config_info_3 [0 ] == str (isort_cfg_file )
288- assert config_info_3 [0 ] == str (isort_cfg_file ) and config_info_3 [1 ]["profile" ] == "black"
289+ assert config_info_3 [0 ] == str (isort_cfg_file )
290+ assert config_info_3 [1 ]["profile" ] == "black"
289291
290292 config_info_4 = config_trie .search (str (tmpdir / "file4.py" ))
291293 assert config_info_4 [0 ] == "default"
0 commit comments