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

Skip to content

Commit 3998915

Browse files
Issue #19600: Use specific asserts in distutils tests.
1 parent 5665bc5 commit 3998915

16 files changed

Lines changed: 36 additions & 36 deletions

Lib/distutils/tests/test_archive_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def test_compress_deprecated(self):
210210
dry_run=True)
211211
finally:
212212
os.chdir(old_dir)
213-
self.assertTrue(not os.path.exists(tarball))
213+
self.assertFalse(os.path.exists(tarball))
214214
self.assertEqual(len(w.warnings), 1)
215215

216216
@unittest.skipUnless(ZIP_SUPPORT and ZLIB_SUPPORT,

Lib/distutils/tests/test_bdist_rpm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def test_quiet(self):
8181
cmd.run()
8282

8383
dist_created = os.listdir(os.path.join(pkg_dir, 'dist'))
84-
self.assertTrue('foo-0.1-1.noarch.rpm' in dist_created)
84+
self.assertIn('foo-0.1-1.noarch.rpm', dist_created)
8585

8686
# bug #2945: upload ignores bdist_rpm files
8787
self.assertIn(('bdist_rpm', 'any', 'dist/foo-0.1-1.src.rpm'), dist.dist_files)
@@ -125,7 +125,7 @@ def test_no_optimize_flag(self):
125125
cmd.run()
126126

127127
dist_created = os.listdir(os.path.join(pkg_dir, 'dist'))
128-
self.assertTrue('foo-0.1-1.noarch.rpm' in dist_created)
128+
self.assertIn('foo-0.1-1.noarch.rpm', dist_created)
129129

130130
# bug #2945: upload ignores bdist_rpm files
131131
self.assertIn(('bdist_rpm', 'any', 'dist/foo-0.1-1.src.rpm'), dist.dist_files)

Lib/distutils/tests/test_bdist_wininst.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def test_get_exe_bytes(self):
2222
# and make sure it finds it and returns its content
2323
# no matter what platform we have
2424
exe_file = cmd.get_exe_bytes()
25-
self.assertTrue(len(exe_file) > 10)
25+
self.assertGreater(len(exe_file), 10)
2626

2727
def test_suite():
2828
return unittest.makeSuite(BuildWinInstTestCase)

Lib/distutils/tests/test_build_clib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def test_run(self):
137137
cmd.run()
138138

139139
# let's check the result
140-
self.assertTrue('libfoo.a' in os.listdir(build_temp))
140+
self.assertIn('libfoo.a', os.listdir(build_temp))
141141

142142
def test_suite():
143143
return unittest.makeSuite(BuildCLibTestCase)

Lib/distutils/tests/test_build_ext.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ def test_build_ext(self):
7676
if support.HAVE_DOCSTRINGS:
7777
doc = 'This is a template module just for instruction.'
7878
self.assertEqual(xx.__doc__, doc)
79-
self.assertTrue(isinstance(xx.Null(), xx.Null))
80-
self.assertTrue(isinstance(xx.Str(), xx.Str))
79+
self.assertIsInstance(xx.Null(), xx.Null)
80+
self.assertIsInstance(xx.Str(), xx.Str)
8181

8282
def tearDown(self):
8383
# Get everything back to normal
@@ -110,7 +110,7 @@ def test_solaris_enable_shared(self):
110110
_config_vars['Py_ENABLE_SHARED'] = old_var
111111

112112
# make sure we get some library dirs under solaris
113-
self.assertTrue(len(cmd.library_dirs) > 0)
113+
self.assertGreater(len(cmd.library_dirs), 0)
114114

115115
def test_user_site(self):
116116
# site.USER_SITE was introduced in 2.6
@@ -124,7 +124,7 @@ def test_user_site(self):
124124
# making sure the user option is there
125125
options = [name for name, short, lable in
126126
cmd.user_options]
127-
self.assertTrue('user' in options)
127+
self.assertIn('user', options)
128128

129129
# setting a value
130130
cmd.user = 1
@@ -171,10 +171,10 @@ def test_finalize_options(self):
171171

172172
from distutils import sysconfig
173173
py_include = sysconfig.get_python_inc()
174-
self.assertTrue(py_include in cmd.include_dirs)
174+
self.assertIn(py_include, cmd.include_dirs)
175175

176176
plat_py_include = sysconfig.get_python_inc(plat_specific=1)
177-
self.assertTrue(plat_py_include in cmd.include_dirs)
177+
self.assertIn(plat_py_include, cmd.include_dirs)
178178

179179
# make sure cmd.libraries is turned into a list
180180
# if it's a string
@@ -255,13 +255,13 @@ def test_check_extensions_list(self):
255255
'some': 'bar'})]
256256
cmd.check_extensions_list(exts)
257257
ext = exts[0]
258-
self.assertTrue(isinstance(ext, Extension))
258+
self.assertIsInstance(ext, Extension)
259259

260260
# check_extensions_list adds in ext the values passed
261261
# when they are in ('include_dirs', 'library_dirs', 'libraries'
262262
# 'extra_objects', 'extra_compile_args', 'extra_link_args')
263263
self.assertEqual(ext.libraries, 'foo')
264-
self.assertTrue(not hasattr(ext, 'some'))
264+
self.assertFalse(hasattr(ext, 'some'))
265265

266266
# 'macros' element of build info dict must be 1- or 2-tuple
267267
exts = [('foo.bar', {'sources': [''], 'libraries': 'foo',

Lib/distutils/tests/test_build_scripts.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ class BuildScriptsTestCase(support.TempdirManager,
1717

1818
def test_default_settings(self):
1919
cmd = self.get_build_scripts_cmd("/foo/bar", [])
20-
self.assertTrue(not cmd.force)
21-
self.assertTrue(cmd.build_dir is None)
20+
self.assertFalse(cmd.force)
21+
self.assertIsNone(cmd.build_dir)
2222

2323
cmd.finalize_options()
2424

@@ -38,7 +38,7 @@ def test_build(self):
3838

3939
built = os.listdir(target)
4040
for name in expected:
41-
self.assertTrue(name in built)
41+
self.assertIn(name, built)
4242

4343
def get_build_scripts_cmd(self, target, scripts):
4444
import sys
@@ -103,7 +103,7 @@ def test_version_int(self):
103103

104104
built = os.listdir(target)
105105
for name in expected:
106-
self.assertTrue(name in built)
106+
self.assertIn(name, built)
107107

108108
def test_suite():
109109
return unittest.makeSuite(BuildScriptsTestCase)

Lib/distutils/tests/test_clean.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def test_simple_run(self):
3636

3737
# make sure the files where removed
3838
for name, path in dirs:
39-
self.assertTrue(not os.path.exists(path),
39+
self.assertFalse(os.path.exists(path),
4040
'%s was not removed' % path)
4141

4242
# let's run the command again (should spit warnings but succeed)

Lib/distutils/tests/test_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def test_server_registration(self):
103103
def test_server_empty_registration(self):
104104
cmd = self._cmd(self.dist)
105105
rc = cmd._get_rc_file()
106-
self.assertTrue(not os.path.exists(rc))
106+
self.assertFalse(os.path.exists(rc))
107107
cmd._store_pypirc('tarek', 'xxx')
108108
self.assertTrue(os.path.exists(rc))
109109
f = open(rc)

Lib/distutils/tests/test_config_cmd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def test_clean(self):
8181
cmd._clean(f1, f2)
8282

8383
for f in (f1, f2):
84-
self.assertTrue(not os.path.exists(f))
84+
self.assertFalse(os.path.exists(f))
8585

8686
def test_suite():
8787
return unittest.makeSuite(ConfigTestCase)

Lib/distutils/tests/test_install.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def test_debug_mode(self):
236236
self.test_record()
237237
finally:
238238
install_module.DEBUG = False
239-
self.assertTrue(len(self.logs) > old_logs_len)
239+
self.assertGreater(len(self.logs), old_logs_len)
240240

241241

242242
def test_suite():

0 commit comments

Comments
 (0)