Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 19f2aeb

Browse files
committed
Merged revisions 86596 via svnmerge from
svn+ssh://[email protected]/python/branches/py3k ........ r86596 | ezio.melotti | 2010-11-20 21:04:17 +0200 (Sat, 20 Nov 2010) | 1 line #9424: Replace deprecated assert* methods in the Python test suite. ........
1 parent b65b493 commit 19f2aeb

164 files changed

Lines changed: 2288 additions & 2286 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Lib/ctypes/test/test_keeprefs.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
class SimpleTestCase(unittest.TestCase):
55
def test_cint(self):
66
x = c_int()
7-
self.assertEquals(x._objects, None)
7+
self.assertEqual(x._objects, None)
88
x.value = 42
9-
self.assertEquals(x._objects, None)
9+
self.assertEqual(x._objects, None)
1010
x = c_int(99)
11-
self.assertEquals(x._objects, None)
11+
self.assertEqual(x._objects, None)
1212

1313
def test_ccharp(self):
1414
x = c_char_p()
15-
self.assertEquals(x._objects, None)
15+
self.assertEqual(x._objects, None)
1616
x.value = "abc"
17-
self.assertEquals(x._objects, b"abc")
17+
self.assertEqual(x._objects, b"abc")
1818
x = c_char_p("spam")
19-
self.assertEquals(x._objects, b"spam")
19+
self.assertEqual(x._objects, b"spam")
2020

2121
class StructureTestCase(unittest.TestCase):
2222
def test_cint_struct(self):
@@ -25,21 +25,21 @@ class X(Structure):
2525
("b", c_int)]
2626

2727
x = X()
28-
self.assertEquals(x._objects, None)
28+
self.assertEqual(x._objects, None)
2929
x.a = 42
3030
x.b = 99
31-
self.assertEquals(x._objects, None)
31+
self.assertEqual(x._objects, None)
3232

3333
def test_ccharp_struct(self):
3434
class X(Structure):
3535
_fields_ = [("a", c_char_p),
3636
("b", c_char_p)]
3737
x = X()
38-
self.assertEquals(x._objects, None)
38+
self.assertEqual(x._objects, None)
3939

4040
x.a = "spam"
4141
x.b = "foo"
42-
self.assertEquals(x._objects, {"0": b"spam", "1": b"foo"})
42+
self.assertEqual(x._objects, {"0": b"spam", "1": b"foo"})
4343

4444
def test_struct_struct(self):
4545
class POINT(Structure):
@@ -52,28 +52,28 @@ class RECT(Structure):
5252
r.ul.y = 1
5353
r.lr.x = 2
5454
r.lr.y = 3
55-
self.assertEquals(r._objects, None)
55+
self.assertEqual(r._objects, None)
5656

5757
r = RECT()
5858
pt = POINT(1, 2)
5959
r.ul = pt
60-
self.assertEquals(r._objects, {'0': {}})
60+
self.assertEqual(r._objects, {'0': {}})
6161
r.ul.x = 22
6262
r.ul.y = 44
63-
self.assertEquals(r._objects, {'0': {}})
63+
self.assertEqual(r._objects, {'0': {}})
6464
r.lr = POINT()
65-
self.assertEquals(r._objects, {'0': {}, '1': {}})
65+
self.assertEqual(r._objects, {'0': {}, '1': {}})
6666

6767
class ArrayTestCase(unittest.TestCase):
6868
def test_cint_array(self):
6969
INTARR = c_int * 3
7070

7171
ia = INTARR()
72-
self.assertEquals(ia._objects, None)
72+
self.assertEqual(ia._objects, None)
7373
ia[0] = 1
7474
ia[1] = 2
7575
ia[2] = 3
76-
self.assertEquals(ia._objects, None)
76+
self.assertEqual(ia._objects, None)
7777

7878
class X(Structure):
7979
_fields_ = [("x", c_int),
@@ -83,9 +83,9 @@ class X(Structure):
8383
x.x = 1000
8484
x.a[0] = 42
8585
x.a[1] = 96
86-
self.assertEquals(x._objects, None)
86+
self.assertEqual(x._objects, None)
8787
x.a = ia
88-
self.assertEquals(x._objects, {'1': {}})
88+
self.assertEqual(x._objects, {'1': {}})
8989

9090
class PointerTestCase(unittest.TestCase):
9191
def test_p_cint(self):

Lib/distutils/tests/test_archive_util.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def test_tarfile_vs_tar(self):
113113

114114
self.assertTrue(os.path.exists(tarball2))
115115
# let's compare both tarballs
116-
self.assertEquals(self._tarinfo(tarball), self._tarinfo(tarball2))
116+
self.assertEqual(self._tarinfo(tarball), self._tarinfo(tarball2))
117117

118118
# trying an uncompressed one
119119
base_name = os.path.join(tmpdir2, 'archive')
@@ -153,7 +153,7 @@ def test_compress_deprecated(self):
153153
os.chdir(old_dir)
154154
tarball = base_name + '.tar.Z'
155155
self.assertTrue(os.path.exists(tarball))
156-
self.assertEquals(len(w.warnings), 1)
156+
self.assertEqual(len(w.warnings), 1)
157157

158158
# same test with dry_run
159159
os.remove(tarball)
@@ -167,7 +167,7 @@ def test_compress_deprecated(self):
167167
finally:
168168
os.chdir(old_dir)
169169
self.assertTrue(not os.path.exists(tarball))
170-
self.assertEquals(len(w.warnings), 1)
170+
self.assertEqual(len(w.warnings), 1)
171171

172172
@unittest.skipUnless(ZIP_SUPPORT, 'Need zip support to run')
173173
def test_make_zipfile(self):
@@ -184,9 +184,9 @@ def test_make_zipfile(self):
184184
tarball = base_name + '.zip'
185185

186186
def test_check_archive_formats(self):
187-
self.assertEquals(check_archive_formats(['gztar', 'xxx', 'zip']),
188-
'xxx')
189-
self.assertEquals(check_archive_formats(['gztar', 'zip']), None)
187+
self.assertEqual(check_archive_formats(['gztar', 'xxx', 'zip']),
188+
'xxx')
189+
self.assertEqual(check_archive_formats(['gztar', 'zip']), None)
190190

191191
def test_make_archive(self):
192192
tmpdir = self.mkdtemp()
@@ -203,7 +203,7 @@ def _breaks(*args, **kw):
203203
make_archive('xxx', 'xxx', root_dir=self.mkdtemp())
204204
except:
205205
pass
206-
self.assertEquals(os.getcwd(), current_dir)
206+
self.assertEqual(os.getcwd(), current_dir)
207207
finally:
208208
del ARCHIVE_FORMATS['xxx']
209209

Lib/distutils/tests/test_bdist.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def test_formats(self):
2323
cmd = bdist(dist)
2424
cmd.formats = ['msi']
2525
cmd.ensure_finalized()
26-
self.assertEquals(cmd.formats, ['msi'])
26+
self.assertEqual(cmd.formats, ['msi'])
2727

2828
# what format bdist offers ?
2929
# XXX an explicit list in bdist is
@@ -34,7 +34,7 @@ def test_formats(self):
3434
formats.sort()
3535
founded = list(cmd.format_command.keys())
3636
founded.sort()
37-
self.assertEquals(founded, formats)
37+
self.assertEqual(founded, formats)
3838

3939
def test_suite():
4040
return unittest.makeSuite(BuildTestCase)

Lib/distutils/tests/test_bdist_dumb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def test_simple_built(self):
6868
base = base.replace(':', '-')
6969

7070
wanted = ['%s.zip' % base]
71-
self.assertEquals(dist_created, wanted)
71+
self.assertEqual(dist_created, wanted)
7272

7373
# now let's check what we have in the zip file
7474
# XXX to be done

Lib/distutils/tests/test_build_clib.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ def test_get_source_files(self):
5555
self.assertRaises(DistutilsSetupError, cmd.get_source_files)
5656

5757
cmd.libraries = [('name', {'sources': ['a', 'b']})]
58-
self.assertEquals(cmd.get_source_files(), ['a', 'b'])
58+
self.assertEqual(cmd.get_source_files(), ['a', 'b'])
5959

6060
cmd.libraries = [('name', {'sources': ('a', 'b')})]
61-
self.assertEquals(cmd.get_source_files(), ['a', 'b'])
61+
self.assertEqual(cmd.get_source_files(), ['a', 'b'])
6262

6363
cmd.libraries = [('name', {'sources': ('a', 'b')}),
6464
('name2', {'sources': ['c', 'd']})]
65-
self.assertEquals(cmd.get_source_files(), ['a', 'b', 'c', 'd'])
65+
self.assertEqual(cmd.get_source_files(), ['a', 'b', 'c', 'd'])
6666

6767
def test_build_libraries(self):
6868

@@ -91,11 +91,11 @@ def test_finalize_options(self):
9191

9292
cmd.include_dirs = 'one-dir'
9393
cmd.finalize_options()
94-
self.assertEquals(cmd.include_dirs, ['one-dir'])
94+
self.assertEqual(cmd.include_dirs, ['one-dir'])
9595

9696
cmd.include_dirs = None
9797
cmd.finalize_options()
98-
self.assertEquals(cmd.include_dirs, [])
98+
self.assertEqual(cmd.include_dirs, [])
9999

100100
cmd.distribution.libraries = 'WONTWORK'
101101
self.assertRaises(DistutilsSetupError, cmd.finalize_options)

Lib/distutils/tests/test_build_ext.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ def test_build_ext(self):
9696
for attr in ('error', 'foo', 'new', 'roj'):
9797
self.assertTrue(hasattr(xx, attr))
9898

99-
self.assertEquals(xx.foo(2, 5), 7)
100-
self.assertEquals(xx.foo(13,15), 28)
101-
self.assertEquals(xx.new().demo(), None)
99+
self.assertEqual(xx.foo(2, 5), 7)
100+
self.assertEqual(xx.foo(13,15), 28)
101+
self.assertEqual(xx.new().demo(), None)
102102
doc = 'This is a template module just for instruction.'
103-
self.assertEquals(xx.__doc__, doc)
103+
self.assertEqual(xx.__doc__, doc)
104104
self.assertTrue(isinstance(xx.Null(), xx.Null))
105105
self.assertTrue(isinstance(xx.Str(), xx.Str))
106106

@@ -206,7 +206,7 @@ def test_finalize_options(self):
206206
cmd = build_ext(dist)
207207
cmd.libraries = 'my_lib'
208208
cmd.finalize_options()
209-
self.assertEquals(cmd.libraries, ['my_lib'])
209+
self.assertEqual(cmd.libraries, ['my_lib'])
210210

211211
# make sure cmd.library_dirs is turned into a list
212212
# if it's a string
@@ -220,7 +220,7 @@ def test_finalize_options(self):
220220
cmd = build_ext(dist)
221221
cmd.rpath = os.pathsep.join(['one', 'two'])
222222
cmd.finalize_options()
223-
self.assertEquals(cmd.rpath, ['one', 'two'])
223+
self.assertEqual(cmd.rpath, ['one', 'two'])
224224

225225
# XXX more tests to perform for win32
226226

@@ -229,25 +229,25 @@ def test_finalize_options(self):
229229
cmd = build_ext(dist)
230230
cmd.define = 'one,two'
231231
cmd.finalize_options()
232-
self.assertEquals(cmd.define, [('one', '1'), ('two', '1')])
232+
self.assertEqual(cmd.define, [('one', '1'), ('two', '1')])
233233

234234
# make sure undef is turned into a list of
235235
# strings if they are ','-separated strings
236236
cmd = build_ext(dist)
237237
cmd.undef = 'one,two'
238238
cmd.finalize_options()
239-
self.assertEquals(cmd.undef, ['one', 'two'])
239+
self.assertEqual(cmd.undef, ['one', 'two'])
240240

241241
# make sure swig_opts is turned into a list
242242
cmd = build_ext(dist)
243243
cmd.swig_opts = None
244244
cmd.finalize_options()
245-
self.assertEquals(cmd.swig_opts, [])
245+
self.assertEqual(cmd.swig_opts, [])
246246

247247
cmd = build_ext(dist)
248248
cmd.swig_opts = '1 2'
249249
cmd.finalize_options()
250-
self.assertEquals(cmd.swig_opts, ['1', '2'])
250+
self.assertEqual(cmd.swig_opts, ['1', '2'])
251251

252252
def test_check_extensions_list(self):
253253
dist = Distribution()
@@ -283,7 +283,7 @@ def test_check_extensions_list(self):
283283
# check_extensions_list adds in ext the values passed
284284
# when they are in ('include_dirs', 'library_dirs', 'libraries'
285285
# 'extra_objects', 'extra_compile_args', 'extra_link_args')
286-
self.assertEquals(ext.libraries, 'foo')
286+
self.assertEqual(ext.libraries, 'foo')
287287
self.assertTrue(not hasattr(ext, 'some'))
288288

289289
# 'macros' element of build info dict must be 1- or 2-tuple
@@ -293,15 +293,15 @@ def test_check_extensions_list(self):
293293

294294
exts[0][1]['macros'] = [('1', '2'), ('3',)]
295295
cmd.check_extensions_list(exts)
296-
self.assertEquals(exts[0].undef_macros, ['3'])
297-
self.assertEquals(exts[0].define_macros, [('1', '2')])
296+
self.assertEqual(exts[0].undef_macros, ['3'])
297+
self.assertEqual(exts[0].define_macros, [('1', '2')])
298298

299299
def test_get_source_files(self):
300300
modules = [Extension('foo', ['xxx'], optional=False)]
301301
dist = Distribution({'name': 'xx', 'ext_modules': modules})
302302
cmd = build_ext(dist)
303303
cmd.ensure_finalized()
304-
self.assertEquals(cmd.get_source_files(), ['xxx'])
304+
self.assertEqual(cmd.get_source_files(), ['xxx'])
305305

306306
def test_compiler_option(self):
307307
# cmd.compiler is an option and
@@ -312,7 +312,7 @@ def test_compiler_option(self):
312312
cmd.compiler = 'unix'
313313
cmd.ensure_finalized()
314314
cmd.run()
315-
self.assertEquals(cmd.compiler, 'unix')
315+
self.assertEqual(cmd.compiler, 'unix')
316316

317317
def test_get_outputs(self):
318318
tmp_dir = self.mkdtemp()
@@ -324,7 +324,7 @@ def test_get_outputs(self):
324324
cmd = build_ext(dist)
325325
self._fixup_command(cmd)
326326
cmd.ensure_finalized()
327-
self.assertEquals(len(cmd.get_outputs()), 1)
327+
self.assertEqual(len(cmd.get_outputs()), 1)
328328

329329
if os.name == "nt":
330330
cmd.debug = sys.executable.endswith("_d.exe")
@@ -344,28 +344,28 @@ def test_get_outputs(self):
344344
finally:
345345
os.chdir(old_wd)
346346
self.assertTrue(os.path.exists(so_file))
347-
self.assertEquals(os.path.splitext(so_file)[-1],
348-
sysconfig.get_config_var('SO'))
347+
self.assertEqual(os.path.splitext(so_file)[-1],
348+
sysconfig.get_config_var('SO'))
349349
so_dir = os.path.dirname(so_file)
350-
self.assertEquals(so_dir, other_tmp_dir)
350+
self.assertEqual(so_dir, other_tmp_dir)
351351

352352
cmd.inplace = 0
353353
cmd.compiler = None
354354
cmd.run()
355355
so_file = cmd.get_outputs()[0]
356356
self.assertTrue(os.path.exists(so_file))
357-
self.assertEquals(os.path.splitext(so_file)[-1],
358-
sysconfig.get_config_var('SO'))
357+
self.assertEqual(os.path.splitext(so_file)[-1],
358+
sysconfig.get_config_var('SO'))
359359
so_dir = os.path.dirname(so_file)
360-
self.assertEquals(so_dir, cmd.build_lib)
360+
self.assertEqual(so_dir, cmd.build_lib)
361361

362362
# inplace = 0, cmd.package = 'bar'
363363
build_py = cmd.get_finalized_command('build_py')
364364
build_py.package_dir = {'': 'bar'}
365365
path = cmd.get_ext_fullpath('foo')
366366
# checking that the last directory is the build_dir
367367
path = os.path.split(path)[0]
368-
self.assertEquals(path, cmd.build_lib)
368+
self.assertEqual(path, cmd.build_lib)
369369

370370
# inplace = 1, cmd.package = 'bar'
371371
cmd.inplace = 1
@@ -379,7 +379,7 @@ def test_get_outputs(self):
379379
# checking that the last directory is bar
380380
path = os.path.split(path)[0]
381381
lastdir = os.path.split(path)[-1]
382-
self.assertEquals(lastdir, 'bar')
382+
self.assertEqual(lastdir, 'bar')
383383

384384
def test_ext_fullpath(self):
385385
ext = sysconfig.get_config_vars()['SO']
@@ -395,14 +395,14 @@ def test_ext_fullpath(self):
395395
curdir = os.getcwd()
396396
wanted = os.path.join(curdir, 'src', 'lxml', 'etree' + ext)
397397
path = cmd.get_ext_fullpath('lxml.etree')
398-
self.assertEquals(wanted, path)
398+
self.assertEqual(wanted, path)
399399

400400
# building lxml.etree not inplace
401401
cmd.inplace = 0
402402
cmd.build_lib = os.path.join(curdir, 'tmpdir')
403403
wanted = os.path.join(curdir, 'tmpdir', 'lxml', 'etree' + ext)
404404
path = cmd.get_ext_fullpath('lxml.etree')
405-
self.assertEquals(wanted, path)
405+
self.assertEqual(wanted, path)
406406

407407
# building twisted.runner.portmap not inplace
408408
build_py = cmd.get_finalized_command('build_py')
@@ -411,13 +411,13 @@ def test_ext_fullpath(self):
411411
path = cmd.get_ext_fullpath('twisted.runner.portmap')
412412
wanted = os.path.join(curdir, 'tmpdir', 'twisted', 'runner',
413413
'portmap' + ext)
414-
self.assertEquals(wanted, path)
414+
self.assertEqual(wanted, path)
415415

416416
# building twisted.runner.portmap inplace
417417
cmd.inplace = 1
418418
path = cmd.get_ext_fullpath('twisted.runner.portmap')
419419
wanted = os.path.join(curdir, 'twisted', 'runner', 'portmap' + ext)
420-
self.assertEquals(wanted, path)
420+
self.assertEqual(wanted, path)
421421

422422
def test_suite():
423423
src = _get_source_filename()

0 commit comments

Comments
 (0)