Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf48ef31

Browse files
committed
src, config_tc: replace deprecatedfailUnlessRaises
1 parent794187f commitf48ef31

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

‎git/test/test_config.py

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ def test_read_write(self):
6060
self.assertEqual(file_obj.getvalue(),self._to_memcache(fixture_path(filename)).getvalue())
6161

6262
# creating an additional config writer must fail due to exclusive access
63-
self.failUnlessRaises(IOError,GitConfigParser,file_obj,read_only=False)
63+
withself.assertRaises(IOError):
64+
GitConfigParser(file_obj,read_only=False)
6465

6566
# should still have a lock and be able to make changes
6667
assertw_config._lock._has_lock()
@@ -91,18 +92,21 @@ def test_read_write(self):
9192
@with_rw_directory
9293
deftest_lock_reentry(self,rw_dir):
9394
fpl=os.path.join(rw_dir,'l')
94-
withGitConfigParser(fpl,read_only=False)asgcp:
95-
gcp.set_value('include','some_value','a')
95+
gcp=GitConfigParser(fpl,read_only=False)
96+
withgcpascw:
97+
cw.set_value('include','some_value','a')
9698
# entering again locks the file again...
9799
withgcpascw:
98100
cw.set_value('include','some_other_value','b')
99101
# ...so creating an additional config writer must fail due to exclusive access
100-
self.failUnlessRaises(IOError,GitConfigParser,fpl,read_only=False)
102+
withself.assertRaises(IOError):
103+
GitConfigParser(fpl,read_only=False)
101104
# but work when the lock is removed
102105
withGitConfigParser(fpl,read_only=False):
103106
assertos.path.exists(fpl)
104107
# reentering with an existing lock must fail due to exclusive access
105-
self.failUnlessRaises(IOError,gcp.__enter__)
108+
withself.assertRaises(IOError):
109+
gcp.__enter__()
106110

107111
deftest_multi_line_config(self):
108112
file_obj=self._to_memcache(fixture_path("git_config_with_comments"))
@@ -144,10 +148,13 @@ def test_base(self):
144148
assert"\n"notinval
145149

146150
# writing must fail
147-
self.failUnlessRaises(IOError,r_config.set,section,option,None)
148-
self.failUnlessRaises(IOError,r_config.remove_option,section,option)
151+
withself.assertRaises(IOError):
152+
r_config.set(section,option,None)
153+
withself.assertRaises(IOError):
154+
r_config.remove_option(section,option)
149155
# END for each option
150-
self.failUnlessRaises(IOError,r_config.remove_section,section)
156+
withself.assertRaises(IOError):
157+
r_config.remove_section(section)
151158
# END for each section
152159
assertnum_sectionsandnum_options
153160
assertr_config._is_initializedisTrue
@@ -157,7 +164,8 @@ def test_base(self):
157164
assertr_config.get_value("doesnt","exist",default)==default
158165

159166
# it raises if there is no default though
160-
self.failUnlessRaises(cp.NoSectionError,r_config.get_value,"doesnt","exist")
167+
withself.assertRaises(cp.NoSectionError):
168+
r_config.get_value("doesnt","exist")
161169

162170
@with_rw_directory
163171
deftest_config_include(self,rw_dir):
@@ -206,7 +214,8 @@ def check_test_value(cr, value):
206214
write_test_value(cw,tv)
207215

208216
withGitConfigParser(fpa,read_only=True)ascr:
209-
self.failUnlessRaises(cp.NoSectionError,check_test_value,cr,tv)
217+
withself.assertRaises(cp.NoSectionError):
218+
check_test_value(cr,tv)
210219

211220
# But can make it skip includes alltogether, and thus allow write-backs
212221
withGitConfigParser(fpa,read_only=False,merge_includes=False)ascw:
@@ -218,8 +227,10 @@ def check_test_value(cr, value):
218227
deftest_rename(self):
219228
file_obj=self._to_memcache(fixture_path('git_config'))
220229
withGitConfigParser(file_obj,read_only=False,merge_includes=False)ascw:
221-
self.failUnlessRaises(ValueError,cw.rename_section,"doesntexist","foo")
222-
self.failUnlessRaises(ValueError,cw.rename_section,"core","include")
230+
withself.assertRaises(ValueError):
231+
cw.rename_section("doesntexist","foo")
232+
withself.assertRaises(ValueError):
233+
cw.rename_section("core","include")
223234

224235
nn="bee"
225236
assertcw.rename_section('core',nn)iscw
@@ -237,4 +248,5 @@ def test_empty_config_value(self):
237248

238249
assertcr.get_value('core','filemode'),"Should read keys with values"
239250

240-
self.failUnlessRaises(cp.NoOptionError,cr.get_value,'color','ui')
251+
withself.assertRaises(cp.NoOptionError):
252+
cr.get_value('color','ui')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp