diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-11-16 22:20:12 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-11-16 22:20:12 (GMT) |
commit | 932c6160b58396d97efdf82779a76c4f648a75f8 (patch) | |
tree | 56629e86df5d97bcf9d875f79eb5489bc6052310 | |
parent | bc39869095d1d24084965d2c41056750ec579763 (diff) | |
parent | 39989157add83040a3d29a1bd0a04142ad98d7db (diff) | |
download | cpython-932c6160b58396d97efdf82779a76c4f648a75f8.zip cpython-932c6160b58396d97efdf82779a76c4f648a75f8.tar.gz cpython-932c6160b58396d97efdf82779a76c4f648a75f8.tar.bz2 |
Issue #19600: Use specific asserts in distutils tests.
-rw-r--r-- | Lib/distutils/tests/test_archive_util.py | 2 | ||||
-rw-r--r-- | Lib/distutils/tests/test_bdist_rpm.py | 4 | ||||
-rw-r--r-- | Lib/distutils/tests/test_bdist_wininst.py | 2 | ||||
-rw-r--r-- | Lib/distutils/tests/test_build_clib.py | 2 | ||||
-rw-r--r-- | Lib/distutils/tests/test_build_ext.py | 16 | ||||
-rw-r--r-- | Lib/distutils/tests/test_build_scripts.py | 8 | ||||
-rw-r--r-- | Lib/distutils/tests/test_clean.py | 2 | ||||
-rw-r--r-- | Lib/distutils/tests/test_config.py | 2 | ||||
-rw-r--r-- | Lib/distutils/tests/test_config_cmd.py | 2 | ||||
-rw-r--r-- | Lib/distutils/tests/test_install.py | 2 | ||||
-rw-r--r-- | Lib/distutils/tests/test_install_lib.py | 2 | ||||
-rw-r--r-- | Lib/distutils/tests/test_install_scripts.py | 10 | ||||
-rw-r--r-- | Lib/distutils/tests/test_msvc9compiler.py | 6 | ||||
-rw-r--r-- | Lib/distutils/tests/test_register.py | 8 | ||||
-rw-r--r-- | Lib/distutils/tests/test_sysconfig.py | 2 | ||||
-rw-r--r-- | Lib/distutils/tests/test_util.py | 2 |
16 files changed, 36 insertions, 36 deletions
diff --git a/Lib/distutils/tests/test_archive_util.py b/Lib/distutils/tests/test_archive_util.py index caa0db2..6b42c5a 100644 --- a/Lib/distutils/tests/test_archive_util.py +++ b/Lib/distutils/tests/test_archive_util.py @@ -217,7 +217,7 @@ class ArchiveUtilTestCase(support.TempdirManager, dry_run=True) finally: os.chdir(old_dir) - self.assertTrue(not os.path.exists(tarball)) + self.assertFalse(os.path.exists(tarball)) self.assertEqual(len(w.warnings), 1) @unittest.skipUnless(ZIP_SUPPORT and ZLIB_SUPPORT, diff --git a/Lib/distutils/tests/test_bdist_rpm.py b/Lib/distutils/tests/test_bdist_rpm.py index b090b79..aa1445d 100644 --- a/Lib/distutils/tests/test_bdist_rpm.py +++ b/Lib/distutils/tests/test_bdist_rpm.py @@ -81,7 +81,7 @@ class BuildRpmTestCase(support.TempdirManager, cmd.run() dist_created = os.listdir(os.path.join(pkg_dir, 'dist')) - self.assertTrue('foo-0.1-1.noarch.rpm' in dist_created) + self.assertIn('foo-0.1-1.noarch.rpm', dist_created) # bug #2945: upload ignores bdist_rpm files self.assertIn(('bdist_rpm', 'any', 'dist/foo-0.1-1.src.rpm'), dist.dist_files) @@ -125,7 +125,7 @@ class BuildRpmTestCase(support.TempdirManager, cmd.run() dist_created = os.listdir(os.path.join(pkg_dir, 'dist')) - self.assertTrue('foo-0.1-1.noarch.rpm' in dist_created) + self.assertIn('foo-0.1-1.noarch.rpm', dist_created) # bug #2945: upload ignores bdist_rpm files self.assertIn(('bdist_rpm', 'any', 'dist/foo-0.1-1.src.rpm'), dist.dist_files) diff --git a/Lib/distutils/tests/test_bdist_wininst.py b/Lib/distutils/tests/test_bdist_wininst.py index f9e8f89..5d17ab1 100644 --- a/Lib/distutils/tests/test_bdist_wininst.py +++ b/Lib/distutils/tests/test_bdist_wininst.py @@ -22,7 +22,7 @@ class BuildWinInstTestCase(support.TempdirManager, # and make sure it finds it and returns its content # no matter what platform we have exe_file = cmd.get_exe_bytes() - self.assertTrue(len(exe_file) > 10) + self.assertGreater(len(exe_file), 10) def test_suite(): return unittest.makeSuite(BuildWinInstTestCase) diff --git a/Lib/distutils/tests/test_build_clib.py b/Lib/distutils/tests/test_build_clib.py index ee1c041..c2b981f 100644 --- a/Lib/distutils/tests/test_build_clib.py +++ b/Lib/distutils/tests/test_build_clib.py @@ -137,7 +137,7 @@ class BuildCLibTestCase(support.TempdirManager, cmd.run() # let's check the result - self.assertTrue('libfoo.a' in os.listdir(build_temp)) + self.assertIn('libfoo.a', os.listdir(build_temp)) def test_suite(): return unittest.makeSuite(BuildCLibTestCase) diff --git a/Lib/distutils/tests/test_build_ext.py b/Lib/distutils/tests/test_build_ext.py index 44a9852..3cfaa2c 100644 --- a/Lib/distutils/tests/test_build_ext.py +++ b/Lib/distutils/tests/test_build_ext.py @@ -76,8 +76,8 @@ class BuildExtTestCase(TempdirManager, if support.HAVE_DOCSTRINGS: doc = 'This is a template module just for instruction.' self.assertEqual(xx.__doc__, doc) - self.assertTrue(isinstance(xx.Null(), xx.Null)) - self.assertTrue(isinstance(xx.Str(), xx.Str)) + self.assertIsInstance(xx.Null(), xx.Null) + self.assertIsInstance(xx.Str(), xx.Str) def tearDown(self): # Get everything back to normal @@ -110,7 +110,7 @@ class BuildExtTestCase(TempdirManager, _config_vars['Py_ENABLE_SHARED'] = old_var # make sure we get some library dirs under solaris - self.assertTrue(len(cmd.library_dirs) > 0) + self.assertGreater(len(cmd.library_dirs), 0) def test_user_site(self): # site.USER_SITE was introduced in 2.6 @@ -124,7 +124,7 @@ class BuildExtTestCase(TempdirManager, # making sure the user option is there options = [name for name, short, lable in cmd.user_options] - self.assertTrue('user' in options) + self.assertIn('user', options) # setting a value cmd.user = 1 @@ -171,10 +171,10 @@ class BuildExtTestCase(TempdirManager, from distutils import sysconfig py_include = sysconfig.get_python_inc() - self.assertTrue(py_include in cmd.include_dirs) + self.assertIn(py_include, cmd.include_dirs) plat_py_include = sysconfig.get_python_inc(plat_specific=1) - self.assertTrue(plat_py_include in cmd.include_dirs) + self.assertIn(plat_py_include, cmd.include_dirs) # make sure cmd.libraries is turned into a list # if it's a string @@ -255,13 +255,13 @@ class BuildExtTestCase(TempdirManager, 'some': 'bar'})] cmd.check_extensions_list(exts) ext = exts[0] - self.assertTrue(isinstance(ext, Extension)) + self.assertIsInstance(ext, Extension) # check_extensions_list adds in ext the values passed # when they are in ('include_dirs', 'library_dirs', 'libraries' # 'extra_objects', 'extra_compile_args', 'extra_link_args') self.assertEqual(ext.libraries, 'foo') - self.assertTrue(not hasattr(ext, 'some')) + self.assertFalse(hasattr(ext, 'some')) # 'macros' element of build info dict must be 1- or 2-tuple exts = [('foo.bar', {'sources': [''], 'libraries': 'foo', diff --git a/Lib/distutils/tests/test_build_scripts.py b/Lib/distutils/tests/test_build_scripts.py index e3326b8..954fc76 100644 --- a/Lib/distutils/tests/test_build_scripts.py +++ b/Lib/distutils/tests/test_build_scripts.py @@ -17,8 +17,8 @@ class BuildScriptsTestCase(support.TempdirManager, def test_default_settings(self): cmd = self.get_build_scripts_cmd("/foo/bar", []) - self.assertTrue(not cmd.force) - self.assertTrue(cmd.build_dir is None) + self.assertFalse(cmd.force) + self.assertIsNone(cmd.build_dir) cmd.finalize_options() @@ -38,7 +38,7 @@ class BuildScriptsTestCase(support.TempdirManager, built = os.listdir(target) for name in expected: - self.assertTrue(name in built) + self.assertIn(name, built) def get_build_scripts_cmd(self, target, scripts): import sys @@ -103,7 +103,7 @@ class BuildScriptsTestCase(support.TempdirManager, built = os.listdir(target) for name in expected: - self.assertTrue(name in built) + self.assertIn(name, built) def test_suite(): return unittest.makeSuite(BuildScriptsTestCase) diff --git a/Lib/distutils/tests/test_clean.py b/Lib/distutils/tests/test_clean.py index eb8958b..b64f300 100644 --- a/Lib/distutils/tests/test_clean.py +++ b/Lib/distutils/tests/test_clean.py @@ -36,7 +36,7 @@ class cleanTestCase(support.TempdirManager, # make sure the files where removed for name, path in dirs: - self.assertTrue(not os.path.exists(path), + self.assertFalse(os.path.exists(path), '%s was not removed' % path) # let's run the command again (should spit warnings but succeed) diff --git a/Lib/distutils/tests/test_config.py b/Lib/distutils/tests/test_config.py index 1259361..4de825a 100644 --- a/Lib/distutils/tests/test_config.py +++ b/Lib/distutils/tests/test_config.py @@ -103,7 +103,7 @@ class PyPIRCCommandTestCase(support.TempdirManager, def test_server_empty_registration(self): cmd = self._cmd(self.dist) rc = cmd._get_rc_file() - self.assertTrue(not os.path.exists(rc)) + self.assertFalse(os.path.exists(rc)) cmd._store_pypirc('tarek', 'xxx') self.assertTrue(os.path.exists(rc)) f = open(rc) diff --git a/Lib/distutils/tests/test_config_cmd.py b/Lib/distutils/tests/test_config_cmd.py index e2e6e4e..79894c7 100644 --- a/Lib/distutils/tests/test_config_cmd.py +++ b/Lib/distutils/tests/test_config_cmd.py @@ -81,7 +81,7 @@ class ConfigTestCase(support.LoggingSilencer, cmd._clean(f1, f2) for f in (f1, f2): - self.assertTrue(not os.path.exists(f)) + self.assertFalse(os.path.exists(f)) def test_suite(): return unittest.makeSuite(ConfigTestCase) diff --git a/Lib/distutils/tests/test_install.py b/Lib/distutils/tests/test_install.py index 42bd269..18e1e57 100644 --- a/Lib/distutils/tests/test_install.py +++ b/Lib/distutils/tests/test_install.py @@ -236,7 +236,7 @@ class InstallTestCase(support.TempdirManager, self.test_record() finally: install_module.DEBUG = False - self.assertTrue(len(self.logs) > old_logs_len) + self.assertGreater(len(self.logs), old_logs_len) def test_suite(): diff --git a/Lib/distutils/tests/test_install_lib.py b/Lib/distutils/tests/test_install_lib.py index dbb3e9a..40dd1a9 100644 --- a/Lib/distutils/tests/test_install_lib.py +++ b/Lib/distutils/tests/test_install_lib.py @@ -105,7 +105,7 @@ class InstallLibTestCase(support.TempdirManager, finally: sys.dont_write_bytecode = old_dont_write_bytecode - self.assertTrue('byte-compiling is disabled' in self.logs[0][1]) + self.assertIn('byte-compiling is disabled', self.logs[0][1]) def test_suite(): diff --git a/Lib/distutils/tests/test_install_scripts.py b/Lib/distutils/tests/test_install_scripts.py index 8952e74..1f7b103 100644 --- a/Lib/distutils/tests/test_install_scripts.py +++ b/Lib/distutils/tests/test_install_scripts.py @@ -24,10 +24,10 @@ class InstallScriptsTestCase(support.TempdirManager, skip_build=1, ) cmd = install_scripts(dist) - self.assertTrue(not cmd.force) - self.assertTrue(not cmd.skip_build) - self.assertTrue(cmd.build_dir is None) - self.assertTrue(cmd.install_dir is None) + self.assertFalse(cmd.force) + self.assertFalse(cmd.skip_build) + self.assertIsNone(cmd.build_dir) + self.assertIsNone(cmd.install_dir) cmd.finalize_options() @@ -72,7 +72,7 @@ class InstallScriptsTestCase(support.TempdirManager, installed = os.listdir(target) for name in expected: - self.assertTrue(name in installed) + self.assertIn(name, installed) def test_suite(): diff --git a/Lib/distutils/tests/test_msvc9compiler.py b/Lib/distutils/tests/test_msvc9compiler.py index 301d43d..5e18c61 100644 --- a/Lib/distutils/tests/test_msvc9compiler.py +++ b/Lib/distutils/tests/test_msvc9compiler.py @@ -128,7 +128,7 @@ class msvc9compilerTestCase(support.TempdirManager, # windows registeries versions. path = r'Control Panel\Desktop' v = Reg.get_value(path, 'dragfullwindows') - self.assertTrue(v in ('0', '1', '2')) + self.assertIn(v, ('0', '1', '2')) import winreg HKCU = winreg.HKEY_CURRENT_USER @@ -136,7 +136,7 @@ class msvc9compilerTestCase(support.TempdirManager, self.assertEqual(keys, None) keys = Reg.read_keys(HKCU, r'Control Panel') - self.assertTrue('Desktop' in keys) + self.assertIn('Desktop', keys) def test_remove_visual_c_ref(self): from distutils.msvc9compiler import MSVCCompiler @@ -174,7 +174,7 @@ class msvc9compilerTestCase(support.TempdirManager, compiler = MSVCCompiler() got = compiler._remove_visual_c_ref(manifest) - self.assertIs(got, None) + self.assertIsNone(got) def test_suite(): diff --git a/Lib/distutils/tests/test_register.py b/Lib/distutils/tests/test_register.py index a86b860..f4efa13 100644 --- a/Lib/distutils/tests/test_register.py +++ b/Lib/distutils/tests/test_register.py @@ -98,7 +98,7 @@ class RegisterTestCase(PyPIRCCommandTestCase): cmd = self._get_cmd() # we shouldn't have a .pypirc file yet - self.assertTrue(not os.path.exists(self.rc)) + self.assertFalse(os.path.exists(self.rc)) # patching input and getpass.getpass # so register gets happy @@ -145,7 +145,7 @@ class RegisterTestCase(PyPIRCCommandTestCase): self.assertEqual(req1['Content-length'], '1374') self.assertEqual(req2['Content-length'], '1374') - self.assertTrue((b'xxx') in self.conn.reqs[1].data) + self.assertIn(b'xxx', self.conn.reqs[1].data) def test_password_not_in_file(self): @@ -175,7 +175,7 @@ class RegisterTestCase(PyPIRCCommandTestCase): req = self.conn.reqs[0] headers = dict(req.headers) self.assertEqual(headers['Content-length'], '608') - self.assertTrue((b'tarek') in req.data) + self.assertIn(b'tarek', req.data) def test_password_reset(self): # this test runs choice 3 @@ -193,7 +193,7 @@ class RegisterTestCase(PyPIRCCommandTestCase): req = self.conn.reqs[0] headers = dict(req.headers) self.assertEqual(headers['Content-length'], '290') - self.assertTrue((b'tarek') in req.data) + self.assertIn(b'tarek', req.data) @unittest.skipUnless(docutils is not None, 'needs docutils') def test_strict(self): diff --git a/Lib/distutils/tests/test_sysconfig.py b/Lib/distutils/tests/test_sysconfig.py index 826ea42..07812d8 100644 --- a/Lib/distutils/tests/test_sysconfig.py +++ b/Lib/distutils/tests/test_sysconfig.py @@ -50,7 +50,7 @@ class SysconfigTestCase(support.EnvironGuard, def test_get_config_vars(self): cvars = sysconfig.get_config_vars() - self.assertTrue(isinstance(cvars, dict)) + self.assertIsInstance(cvars, dict) self.assertTrue(cvars) def test_srcdir(self): diff --git a/Lib/distutils/tests/test_util.py b/Lib/distutils/tests/test_util.py index b73cfe9..548865c 100644 --- a/Lib/distutils/tests/test_util.py +++ b/Lib/distutils/tests/test_util.py @@ -266,7 +266,7 @@ class UtilTestCase(support.EnvironGuard, unittest.TestCase): self.assertTrue(strtobool(y)) for n in no: - self.assertTrue(not strtobool(n)) + self.assertFalse(strtobool(n)) def test_rfc822_escape(self): header = 'I am a\npoor\nlonesome\nheader\n' |