Commit e743dabd authored by Lennart Regebro's avatar Lennart Regebro

Got rid of deprecated assert_ and assertEquals.

--HG--
branch : distribute
extra : rebase_source : 9d7032bac7db98e445ab6a46b2610c278c691c2d
parent ec0ed856
......@@ -102,21 +102,21 @@ class DependsTests(unittest.TestCase):
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)
......@@ -126,8 +126,8 @@ class DependsTests(unittest.TestCase):
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):
......@@ -144,7 +144,7 @@ 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')
......@@ -189,17 +189,17 @@ class DistroTests(unittest.TestCase):
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,
......@@ -253,12 +253,12 @@ class FeatureTests(unittest.TestCase):
)
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
......@@ -272,33 +272,33 @@ class FeatureTests(unittest.TestCase):
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])
......@@ -315,7 +315,7 @@ class TestCommandTests(unittest.TestCase):
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'])
......
......@@ -86,15 +86,15 @@ class TestDevelopTest(unittest.TestCase):
# 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):
......
......@@ -41,9 +41,9 @@ class TestDistInfo(unittest.TestCase):
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()
......
......@@ -68,7 +68,7 @@ class TestEasyInstallTest(unittest.TestCase):
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)
......@@ -81,7 +81,7 @@ class TestEasyInstallTest(unittest.TestCase):
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)
......@@ -127,7 +127,7 @@ class TestEasyInstallTest(unittest.TestCase):
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)
......@@ -138,7 +138,7 @@ class TestEasyInstallTest(unittest.TestCase):
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):
......@@ -147,9 +147,9 @@ 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':
......@@ -157,9 +157,9 @@ class TestPTHFileWriter(unittest.TestCase):
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):
......@@ -246,7 +246,7 @@ 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, ]:
......@@ -309,7 +309,7 @@ class TestSetupRequires(unittest.TestCase):
# 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):
......
......@@ -17,9 +17,9 @@ class TestPackageIndex(unittest.TestCase):
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
......@@ -33,9 +33,9 @@ class TestPackageIndex(unittest.TestCase):
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(
......@@ -53,7 +53,7 @@ class TestPackageIndex(unittest.TestCase):
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:
......@@ -95,7 +95,7 @@ class TestPackageIndex(unittest.TestCase):
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):
"""
......@@ -128,11 +128,11 @@ class TestPackageIndex(unittest.TestCase):
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(
......
......@@ -45,7 +45,7 @@ class DistroTests(TestCase):
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'])
......@@ -228,7 +228,7 @@ class EntryPointTests(TestCase):
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]"
......@@ -328,20 +328,20 @@ class RequirementsTests(TestCase):
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):
......@@ -363,14 +363,14 @@ class RequirementsTests(TestCase):
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.
......@@ -489,7 +489,7 @@ class ParseTests(TestCase):
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')
......@@ -577,12 +577,12 @@ class ScriptHeaderTests(TestCase):
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
......
......@@ -43,13 +43,13 @@ class TestSetup(unittest.TestCase):
# 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):
......@@ -58,7 +58,7 @@ class TestSetup(unittest.TestCase):
_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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment