66import tomllib
77from unittest import TestCase
88
9+ import pytest
10+
911from bugwarrior .config import load
1012
1113from ..base import ConfigTest
@@ -60,7 +62,7 @@ def test_path_precedence(self):
6062 try :
6163 config1 = self .create (path1 )
6264 self .create (path2 )
63- self . assertEqual ( load .get_config_path (), config1 )
65+ assert load .get_config_path () == config1
6466 finally :
6567 self .tearDown ()
6668
@@ -69,16 +71,15 @@ def test_legacy(self):
6971 Falls back on .bugwarriorrc if it exists
7072 """
7173 rc = self .create ('.bugwarriorrc' )
72- self . assertEqual ( load .get_config_path (), rc )
74+ assert load .get_config_path () == rc
7375
7476 def test_no_file (self ):
7577 """
7678 If no bugwarriorrc exist anywhere, the path to the prefered one is
7779 returned.
7880 """
79- self .assertEqual (
80- load .get_config_path (),
81- os .path .join (self .tempdir , '.config/bugwarrior/bugwarriorrc' ),
81+ assert load .get_config_path () == os .path .join (
82+ self .tempdir , '.config/bugwarrior/bugwarriorrc'
8283 )
8384
8485 def test_BUGWARRIORRC (self ):
@@ -90,7 +91,7 @@ def test_BUGWARRIORRC(self):
9091 os .environ ['BUGWARRIORRC' ] = rc
9192 self .create ('.bugwarriorrc' )
9293 self .create ('.config/bugwarrior/bugwarriorrc' )
93- self . assertEqual ( load .get_config_path (), rc )
94+ assert load .get_config_path () == rc
9495
9596 def test_BUGWARRIORRC_empty (self ):
9697 """
@@ -99,7 +100,7 @@ def test_BUGWARRIORRC_empty(self):
99100 """
100101 os .environ ['BUGWARRIORRC' ] = ''
101102 rc = self .create ('.config/bugwarrior/bugwarriorrc' )
102- self . assertEqual ( load .get_config_path (), rc )
103+ assert load .get_config_path () == rc
103104
104105
105106class TestBugwarriorConfigParser (TestCase ):
@@ -112,13 +113,13 @@ def setUp(self):
112113 }
113114
114115 def test_getint (self ):
115- self .assertEqual ( self . config .getint ('general' , 'someint' ), 4 )
116+ assert self .config .getint ('general' , 'someint' ) == 4
116117
117118 def test_getint_none (self ):
118- self .assertEqual ( self . config .getint ('general' , 'somenone' ), None )
119+ assert self .config .getint ('general' , 'somenone' ) is None
119120
120121 def test_getint_valueerror (self ):
121- with self . assertRaises (ValueError ):
122+ with pytest . raises (ValueError ):
122123 self .config .getint ('general' , 'somechar' )
123124
124125
@@ -146,9 +147,7 @@ def test_ini(self):
146147 )
147148 config = load .parse_file (config_path )
148149
149- self .assertEqual (
150- config , {'flavor' : {'general' : {'foo' : 'bar' }}, 'services' : []}
151- )
150+ assert config == {'flavor' : {'general' : {'foo' : 'bar' }}, 'services' : []}
152151
153152 def test_toml_invalid (self ):
154153 config_path = self .create ('.bugwarrior.toml' )
@@ -160,7 +159,7 @@ def test_toml_invalid(self):
160159 """ )
161160 )
162161
163- with self . assertRaises (tomllib .TOMLDecodeError ):
162+ with pytest . raises (tomllib .TOMLDecodeError ):
164163 load .parse_file (config_path )
165164
166165 def test_ini_invalid (self ):
@@ -173,7 +172,7 @@ def test_ini_invalid(self):
173172 """ )
174173 )
175174
176- with self . assertRaises (configparser .MissingSectionHeaderError ):
175+ with pytest . raises (configparser .MissingSectionHeaderError ):
177176 load .parse_file (config_path )
178177
179178 def test_toml_flavors (self ):
@@ -182,9 +181,10 @@ def test_toml_flavors(self):
182181 with open (config_path , 'w' ) as fout :
183182 fout .write ('[flavor.myflavor]\n targets = ["my_gitlab"]' )
184183 config = load .parse_file (config_path )
185- self .assertEqual (
186- config , {'flavor' : {'myflavor' : {'targets' : ['my_gitlab' ]}}, 'services' : []}
187- )
184+ assert config == {
185+ 'flavor' : {'myflavor' : {'targets' : ['my_gitlab' ]}},
186+ 'services' : [],
187+ }
188188
189189 def test_ini_flavors (self ):
190190 config_path = self .create ('.bugwarriorrc' )
@@ -197,9 +197,10 @@ def test_ini_flavors(self):
197197 )
198198 config = load .parse_file (config_path )
199199
200- self .assertEqual (
201- config , {'flavor' : {'myflavor' : {'targets' : 'my_gitlab' }}, 'services' : []}
202- )
200+ assert config == {
201+ 'flavor' : {'myflavor' : {'targets' : 'my_gitlab' }},
202+ 'services' : [],
203+ }
203204
204205 def test_ini_options_renamed (self ):
205206 """
@@ -221,11 +222,11 @@ def test_ini_options_renamed(self):
221222 config = load .parse_file (config_path )
222223
223224 baz_service = next (svc for svc in config ['services' ] if svc ['target' ] == 'baz' )
224- self . assertIn ( 'optionname' , baz_service )
225- self . assertNotIn ( 'prefix.optionname' , baz_service )
225+ assert 'optionname' in baz_service
226+ assert 'prefix.optionname' not in baz_service
226227
227- self . assertIn ( 'log_level' , config ['flavor' ]['general' ])
228- self . assertNotIn ( 'log.level' , config ['flavor' ]['general' ])
228+ assert 'log_level' in config ['flavor' ]['general' ]
229+ assert 'log.level' not in config ['flavor' ]['general' ]
229230
230231 def test_ini_missing_prefix (self ):
231232 config_path = self .create ('.bugwarriorrc' )
@@ -240,7 +241,7 @@ def test_ini_missing_prefix(self):
240241 """ )
241242 )
242243
243- with self . assertRaises (SystemExit ):
244+ with pytest . raises (SystemExit ):
244245 load .parse_file (config_path )
245246
246247 def test_ini_wrong_prefix (self ):
@@ -256,7 +257,7 @@ def test_ini_wrong_prefix(self):
256257 """ )
257258 )
258259
259- with self . assertRaises (SystemExit ):
260+ with pytest . raises (SystemExit ):
260261 load .parse_file (config_path )
261262
262263
@@ -276,8 +277,8 @@ def test_main_section_does_not_exist(self):
276277 """ )
277278 )
278279
279- with self . assertRaises (SystemExit ):
280+ with pytest . raises (SystemExit ):
280281 load .load_config ("general" , False )
281282
282- self . assertEqual ( len (self .caplog .records ), 1 )
283- self . assertIn ( "No section: 'general'" , self .caplog .records [0 ].message )
283+ assert len (self .caplog .records ) == 1
284+ assert "No section: 'general'" in self .caplog .records [0 ].message
0 commit comments