Commits

Lennart Regebro  committed c28e86d Draft

Got rid of deprecated assert_ and assertEquals.

  • Participants
  • Parent commits 5e62f38

Comments (0)

Files changed (7)

File setuptools/tests/__init__.py

 
         from email import __version__
         self.assertEqual(req.get_version(), __version__)
-        self.assert_(req.version_ok('1.0.9'))
-        self.assert_(not req.version_ok('0.9.1'))
-        self.assert_(not req.version_ok('unknown'))
+        self.assertTrue(req.version_ok('1.0.9'))
+        self.assertTrue(not req.version_ok('0.9.1'))
+        self.assertTrue(not req.version_ok('unknown'))
 
-        self.assert_(req.is_present())
-        self.assert_(req.is_current())
+        self.assertTrue(req.is_present())
+        self.assertTrue(req.is_current())
 
         req = Require('Email 3000','03000','email',format=LooseVersion)
-        self.assert_(req.is_present())
-        self.assert_(not req.is_current())
-        self.assert_(not req.version_ok('unknown'))
+        self.assertTrue(req.is_present())
+        self.assertTrue(not req.is_current())
+        self.assertTrue(not req.version_ok('unknown'))
 
         req = Require('Do-what-I-mean','1.0','d-w-i-m')
-        self.assert_(not req.is_present())
-        self.assert_(not req.is_current())
+        self.assertTrue(not req.is_present())
+        self.assertTrue(not req.is_current())
 
         req = Require('Tests', None, 'tests', homepage="http://example.com")
         self.assertEqual(req.format, None)
         self.assertEqual(req.homepage, 'http://example.com')
 
         paths = [os.path.dirname(p) for p in __path__]
-        self.assert_(req.is_present(paths))
-        self.assert_(req.is_current(paths))
+        self.assertTrue(req.is_present(paths))
+        self.assertTrue(req.is_current(paths))
 
 
 class DistroTests(unittest.TestCase):
         )
 
     def testDistroType(self):
-        self.assert_(isinstance(self.dist,setuptools.dist.Distribution))
+        self.assertTrue(isinstance(self.dist,setuptools.dist.Distribution))
 
     def testExcludePackage(self):
         self.dist.exclude_package('a')
         dist.exclude(packages=['a'], py_modules=['b'], ext_modules=[self.e2])
 
     def testContents(self):
-        self.assert_(self.dist.has_contents_for('a'))
+        self.assertTrue(self.dist.has_contents_for('a'))
         self.dist.exclude_package('a')
-        self.assert_(not self.dist.has_contents_for('a'))
+        self.assertTrue(not self.dist.has_contents_for('a'))
 
-        self.assert_(self.dist.has_contents_for('b'))
+        self.assertTrue(self.dist.has_contents_for('b'))
         self.dist.exclude_package('b')
-        self.assert_(not self.dist.has_contents_for('b'))
+        self.assertTrue(not self.dist.has_contents_for('b'))
 
-        self.assert_(self.dist.has_contents_for('c'))
+        self.assertTrue(self.dist.has_contents_for('c'))
         self.dist.exclude_package('c')
-        self.assert_(not self.dist.has_contents_for('c'))
+        self.assertTrue(not self.dist.has_contents_for('c'))
 
     def testInvalidIncludeExclude(self):
         self.assertRaises(DistutilsSetupError,
         )
 
     def testDefaults(self):
-        self.assert_(not
+        self.assertTrue(not
             Feature(
                 "test",standard=True,remove='x',available=False
             ).include_by_default()
         )
-        self.assert_(
+        self.assertTrue(
             Feature("test",standard=True,remove='x').include_by_default()
         )
         # Feature must have either kwargs, removes, or require_features
 
     def testFeatureOptions(self):
         dist = self.dist
-        self.assert_(
+        self.assertTrue(
             ('with-dwim',None,'include DWIM') in dist.feature_options
         )
-        self.assert_(
+        self.assertTrue(
             ('without-dwim',None,'exclude DWIM (default)') in dist.feature_options
         )
-        self.assert_(
+        self.assertTrue(
             ('with-bar',None,'include bar (default)') in dist.feature_options
         )
-        self.assert_(
+        self.assertTrue(
             ('without-bar',None,'exclude bar') in dist.feature_options
         )
         self.assertEqual(dist.feature_negopt['without-foo'],'with-foo')
         self.assertEqual(dist.feature_negopt['without-bar'],'with-bar')
         self.assertEqual(dist.feature_negopt['without-dwim'],'with-dwim')
-        self.assert_(not 'without-baz' in dist.feature_negopt)
+        self.assertTrue(not 'without-baz' in dist.feature_negopt)
 
     def testUseFeatures(self):
         dist = self.dist
         self.assertEqual(dist.with_foo,1)
         self.assertEqual(dist.with_bar,0)
         self.assertEqual(dist.with_baz,1)
-        self.assert_(not 'bar_et' in dist.py_modules)
-        self.assert_(not 'pkg.bar' in dist.packages)
-        self.assert_('pkg.baz' in dist.packages)
-        self.assert_('scripts/baz_it' in dist.scripts)
-        self.assert_(('libfoo','foo/foofoo.c') in dist.libraries)
+        self.assertTrue(not 'bar_et' in dist.py_modules)
+        self.assertTrue(not 'pkg.bar' in dist.packages)
+        self.assertTrue('pkg.baz' in dist.packages)
+        self.assertTrue('scripts/baz_it' in dist.scripts)
+        self.assertTrue(('libfoo','foo/foofoo.c') in dist.libraries)
         self.assertEqual(dist.ext_modules,[])
         self.assertEqual(dist.require_features, [self.req])
 
 
     def testTestIsCommand(self):
         test_cmd = makeSetup().get_command_obj('test')
-        self.assert_(isinstance(test_cmd, distutils.cmd.Command))
+        self.assertTrue(isinstance(test_cmd, distutils.cmd.Command))
 
     def testLongOptSuiteWNoDefault(self):
         ts1 = makeSetup(script_args=['test','--test-suite=foo.tests.suite'])

File setuptools/tests/test_develop.py

         # let's see if we got our egg link at the right place
         content = os.listdir(site.USER_SITE)
         content.sort()
-        self.assertEquals(content, ['easy-install.pth', 'foo.egg-link'])
+        self.assertEqual(content, ['easy-install.pth', 'foo.egg-link'])
 
         # Check that we are using the right code.
         path = open(os.path.join(site.USER_SITE, 'foo.egg-link'), 'rt').read().split()[0].strip()
         init = open(os.path.join(path, 'foo', '__init__.py'), 'rt').read().strip()
         if sys.version < "3":
-            self.assertEquals(init, 'print "foo"')
+            self.assertEqual(init, 'print "foo"')
         else:
-            self.assertEquals(init, 'print("foo")')
+            self.assertEqual(init, 'print("foo")')
 
     def notest_develop_with_setup_requires(self):
 

File setuptools/tests/test_dist_info.py

                     pkg_resources.Requirement.parse('quux>=1.1')]
 
         for d in pkg_resources.find_distributions(self.tmpdir):
-            self.assertEquals(d.requires(), requires[:1])
-            self.assertEquals(d.requires(extras=('baz',)), requires)
-            self.assertEquals(d.extras, ['baz'])
+            self.assertEqual(d.requires(), requires[:1])
+            self.assertEqual(d.requires(extras=('baz',)), requires)
+            self.assertEqual(d.extras, ['baz'])
 
     def setUp(self):
         self.tmpdir = tempfile.mkdtemp()

File setuptools/tests/test_easy_install.py

         try:
             cmd.install_site_py()
             sitepy = os.path.join(cmd.install_dir, 'site.py')
-            self.assert_(os.path.exists(sitepy))
+            self.assertTrue(os.path.exists(sitepy))
         finally:
             shutil.rmtree(cmd.install_dir)
 
         finally:
             sys.platform = old_platform
 
-        self.assertEquals(script, WANTED)
+        self.assertEqual(script, WANTED)
 
     def test_no_setup_cfg(self):
         # makes sure easy_install as a command (main)
         cmd.install_dir = os.path.join(tempfile.mkdtemp(), 'ok')
         cmd.args = ['ok']
         cmd.ensure_finalized()
-        self.assertEquals(cmd.package_index.scanned_urls, {})
+        self.assertEqual(cmd.package_index.scanned_urls, {})
 
         # let's try without it (default behavior)
         cmd = easy_install(dist)
         cmd.ensure_finalized()
         keys = cmd.package_index.scanned_urls.keys()
         keys.sort()
-        self.assertEquals(keys, ['link1', 'link2'])
+        self.assertEqual(keys, ['link1', 'link2'])
 
 
 class TestPTHFileWriter(unittest.TestCase):
         if a distribution is in site but also the cwd
         '''
         pth = PthDistributions('does-not_exist', [os.getcwd()])
-        self.assert_(not pth.dirty)
+        self.assertTrue(not pth.dirty)
         pth.add(PRDistribution(os.getcwd()))
-        self.assert_(pth.dirty)
+        self.assertTrue(pth.dirty)
 
     def test_add_from_site_is_ignored(self):
         if os.name != 'nt':
         else:
             location = 'c:\\does_not_exist'
         pth = PthDistributions('does-not_exist', [location, ])
-        self.assert_(not pth.dirty)
+        self.assertTrue(not pth.dirty)
         pth.add(PRDistribution(location))
-        self.assert_(not pth.dirty)
+        self.assertTrue(not pth.dirty)
 
 
 class TestUserInstallTest(unittest.TestCase):
             cmd.ensure_finalized()
             cmd.local_index.scan([new_location])
             res = cmd.easy_install('foo')
-            self.assertEquals(res.location, new_location)
+            self.assertEqual(res.location, new_location)
         finally:
             sys.path.remove(target)
             for basedir in [new_location, target, ]:
 
         # there should have been two or three requests to the server
         #  (three happens on Python 3.3a)
-        self.assert_(2 <= len(p_index.requests) <= 3)
+        self.assertTrue(2 <= len(p_index.requests) <= 3)
         self.assertEqual(p_index.requests[0].path, '/does-not-exist/')
 
     def create_sdist(self, installer):

File setuptools/tests/test_packageindex.py

         try:
             v = index.open_url(url)
         except Exception, v:
-            self.assert_(url in str(v))
+            self.assertTrue(url in str(v))
         else:
-            self.assert_(isinstance(v,urllib2.HTTPError))
+            self.assertTrue(isinstance(v,urllib2.HTTPError))
 
     def test_bad_url_typo(self):
         # issue 16
         try:
             v = index.open_url(url)
         except Exception, v:
-            self.assert_(url in str(v))
+            self.assertTrue(url in str(v))
         else:
-            self.assert_(isinstance(v, urllib2.HTTPError))
+            self.assertTrue(isinstance(v, urllib2.HTTPError))
 
     def test_bad_url_bad_status_line(self):
         index = setuptools.package_index.PackageIndex(
             try:
                 v = index.open_url(url)
             except Exception, v:
-                self.assert_('line' in str(v))
+                self.assertTrue('line' in str(v))
             else:
                 raise AssertionError('Should have raise here!')
         finally:
             hosts=('www.example.com',)
         )
         url = 'file:///tmp/test_package_index'
-        self.assert_(index.url_ok(url, True))
+        self.assertTrue(index.url_ok(url, True))
 
     def test_links_priority(self):
         """
         server.stop()
 
         # the distribution has been found
-        self.assert_('foobar' in pi)
+        self.assertTrue('foobar' in pi)
         # we have only one link, because links are compared without md5
-        self.assert_(len(pi['foobar'])==1)
+        self.assertTrue(len(pi['foobar'])==1)
         # the link should be from the index
-        self.assert_('correct_md5' in pi['foobar'][0].location)
+        self.assertTrue('correct_md5' in pi['foobar'][0].location)
 
     def test_parse_bdist_wininst(self):
         self.assertEqual(setuptools.package_index.parse_bdist_wininst(

File setuptools/tests/test_resources.py

         ad.add(Distribution.from_filename("FooPkg-1.2-py2.4.egg"))
 
         # Name is in there now
-        self.assert_(ad['FooPkg'])
+        self.assertTrue(ad['FooPkg'])
         # But only 1 package
         self.assertEqual(list(ad), ['foopkg'])
 
         self.assertEqual(ep.module_name,"setuptools.tests.test_resources")
         self.assertEqual(ep.attrs, ("EntryPointTests",))
         self.assertEqual(ep.extras, ("x",))
-        self.assert_(ep.load() is EntryPointTests)
+        self.assertTrue(ep.load() is EntryPointTests)
         self.assertEqual(
             str(ep),
             "foo = setuptools.tests.test_resources:EntryPointTests [x]"
         foo_dist = Distribution.from_filename("FooPkg-1.3_1.egg")
         twist11  = Distribution.from_filename("Twisted-1.1.egg")
         twist12  = Distribution.from_filename("Twisted-1.2.egg")
-        self.assert_(parse_version('1.2') in r)
-        self.assert_(parse_version('1.1') not in r)
-        self.assert_('1.2' in r)
-        self.assert_('1.1' not in r)
-        self.assert_(foo_dist not in r)
-        self.assert_(twist11 not in r)
-        self.assert_(twist12 in r)
+        self.assertTrue(parse_version('1.2') in r)
+        self.assertTrue(parse_version('1.1') not in r)
+        self.assertTrue('1.2' in r)
+        self.assertTrue('1.1' not in r)
+        self.assertTrue(foo_dist not in r)
+        self.assertTrue(twist11 not in r)
+        self.assertTrue(twist12 in r)
 
     def testAdvancedContains(self):
         r, = parse_requirements("Foo>=1.2,<=1.3,==1.9,>2.0,!=2.5,<3.0,==4.5")
         for v in ('1.2','1.2.2','1.3','1.9','2.0.1','2.3','2.6','3.0c1','4.5'):
-            self.assert_(v in r, (v,r))
+            self.assertTrue(v in r, (v,r))
         for v in ('1.2c1','1.3.1','1.5','1.9.1','2.0','2.5','3.0','4.0'):
-            self.assert_(v not in r, (v,r))
+            self.assertTrue(v not in r, (v,r))
 
 
     def testOptionsAndHashing(self):
         r2 = Requirement.parse("foo!=0.3a4")
         d = Distribution.from_filename
 
-        self.assert_(d("foo-0.3a4.egg") not in r1)
-        self.assert_(d("foo-0.3a1.egg") not in r1)
-        self.assert_(d("foo-0.3a4.egg") not in r2)
+        self.assertTrue(d("foo-0.3a4.egg") not in r1)
+        self.assertTrue(d("foo-0.3a1.egg") not in r1)
+        self.assertTrue(d("foo-0.3a4.egg") not in r2)
 
-        self.assert_(d("foo-0.3a2.egg") in r1)
-        self.assert_(d("foo-0.3a2.egg") in r2)
-        self.assert_(d("foo-0.3a3.egg") in r2)
-        self.assert_(d("foo-0.3a5.egg") in r2)
+        self.assertTrue(d("foo-0.3a2.egg") in r1)
+        self.assertTrue(d("foo-0.3a2.egg") in r2)
+        self.assertTrue(d("foo-0.3a3.egg") in r2)
+        self.assertTrue(d("foo-0.3a5.egg") in r2)
 
     def testDistributeSetuptoolsOverride(self):
         # Plain setuptools or distribute mean we return distribute.
     def testVersionOrdering(self):
         def c(s1,s2):
             p1, p2 = parse_version(s1),parse_version(s2)
-            self.assert_(p1<p2, (s1,s2,p1,p2))
+            self.assertTrue(p1<p2, (s1,s2,p1,p2))
 
         c('2.1','2.1.1')
         c('2.1.0','2.10')
             self.assertEqual(get_script_header('#!/usr/bin/python -x',
                                                executable=exe),
                              '#!%s  -x\n' % exe)
-            self.assert_('Unable to adapt shebang line' in sys.stdout.getvalue())
+            self.assertTrue('Unable to adapt shebang line' in sys.stdout.getvalue())
             sys.stdout = sys.stderr = StringIO.StringIO()
             self.assertEqual(get_script_header('#!/usr/bin/python',
                                                executable=self.non_ascii_exe),
                              '#!%s -x\n' % self.non_ascii_exe)
-            self.assert_('Unable to adapt shebang line' in sys.stdout.getvalue())
+            self.assertTrue('Unable to adapt shebang line' in sys.stdout.getvalue())
         finally:
             sys.platform = platform
             sys.stdout = stdout

File tests/test_distribute_setup.py

         # now trying to import it
         sys.path[0] = egg
         import setuptools
-        self.assert_(setuptools.__file__.startswith(egg))
+        self.assertTrue(setuptools.__file__.startswith(egg))
 
     def test_do_download(self):
         tmpdir = tempfile.mkdtemp()
         _do_download(DEFAULT_VERSION, DEFAULT_URL, tmpdir, 1)
         import setuptools
-        self.assert_(setuptools.bootstrap_install_from.startswith(tmpdir))
+        self.assertTrue(setuptools.bootstrap_install_from.startswith(tmpdir))
 
     def test_install(self):
         def _faked(*args):
         _install(self.tarball)
 
     def test_use_setuptools(self):
-        self.assertEquals(use_setuptools(), None)
+        self.assertEqual(use_setuptools(), None)
 
         # make sure fake_setuptools is not called by default
         import pkg_resources