@@ -18,10 +18,9 @@ def test_init(self):
18
18
def test_init_unsupported_settings_fails_gracefully (self ):
19
19
with pytest .raises (exceptions .UnsupportedSettings ):
20
20
Config (apply = True )
21
- try :
21
+ with pytest . raises ( exceptions . UnsupportedSettings ) as error :
22
22
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" }}
25
24
26
25
def test_known_settings (self ):
27
26
assert Config (known_third_party = ["one" ]).known_third_party == frozenset ({"one" })
@@ -35,7 +34,7 @@ def test_invalid_settings_path(self):
35
34
Config (settings_path = "this_couldnt_possibly_actually_exists/could_it" )
36
35
37
36
def test_invalid_pyversion (self ):
38
- with pytest .raises (ValueError ):
37
+ with pytest .raises (ValueError , match = "The python version 10 is not supported." ):
39
38
Config (py_version = 10 )
40
39
41
40
def test_invalid_profile (self ):
@@ -222,11 +221,11 @@ def test_as_bool():
222
221
assert settings ._as_bool ("FALSE" ) is False
223
222
assert settings ._as_bool ("faLSE" ) is False
224
223
assert settings ._as_bool ("f" ) is False
225
- with pytest .raises (ValueError ):
224
+ with pytest .raises (ValueError , match = "invalid truth value" ):
226
225
settings ._as_bool ("" )
227
- with pytest .raises (ValueError ):
226
+ with pytest .raises (ValueError , match = "invalid truth value falsey" ):
228
227
settings ._as_bool ("falsey" )
229
- with pytest .raises (ValueError ):
228
+ with pytest .raises (ValueError , match = "invalid truth value truthy" ):
230
229
settings ._as_bool ("truthy" )
231
230
232
231
@@ -277,15 +276,18 @@ def test_find_all_configs(tmpdir):
277
276
278
277
config_info_1 = config_trie .search (str (dir1 / "test1.py" ))
279
278
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"
281
281
282
282
config_info_2 = config_trie .search (str (dir2 / "test2.py" ))
283
283
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"
285
286
286
287
config_info_3 = config_trie .search (str (dir3 / "test3.py" ))
287
288
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"
289
291
290
292
config_info_4 = config_trie .search (str (tmpdir / "file4.py" ))
291
293
assert config_info_4 [0 ] == "default"
0 commit comments