Anonymous avatar Anonymous committed 48a97bc

Use assertTrue and assertFalse instead of deprecated failUnless and failIf.

Comments (0)

Files changed (2)

setuptools/tests/__init__.py

 
         from email import __version__
         self.assertEqual(req.get_version(), __version__)
-        self.failUnless(req.version_ok('1.0.9'))
-        self.failIf(req.version_ok('0.9.1'))
-        self.failIf(req.version_ok('unknown'))
+        self.assertTrue(req.version_ok('1.0.9'))
+        self.assertFalse(req.version_ok('0.9.1'))
+        self.assertFalse(req.version_ok('unknown'))
 
-        self.failUnless(req.is_present())
-        self.failUnless(req.is_current())
+        self.assertTrue(req.is_present())
+        self.assertTrue(req.is_current())
 
         req = Require('Email 3000','03000','email',format=LooseVersion)
-        self.failUnless(req.is_present())
-        self.failIf(req.is_current())
-        self.failIf(req.version_ok('unknown'))
+        self.assertTrue(req.is_present())
+        self.assertFalse(req.is_current())
+        self.assertFalse(req.version_ok('unknown'))
 
         req = Require('Do-what-I-mean','1.0','d-w-i-m')
-        self.failIf(req.is_present())
-        self.failIf(req.is_current())
+        self.assertFalse(req.is_present())
+        self.assertFalse(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.failUnless(req.is_present(paths))
-        self.failUnless(req.is_current(paths))
+        self.assertTrue(req.is_present(paths))
+        self.assertTrue(req.is_current(paths))
 
 
 class DistroTests(TestCase):
 
 
     def testDistroType(self):
-        self.failUnless(isinstance(self.dist,setuptools.dist.Distribution))
+        self.assertTrue(isinstance(self.dist,setuptools.dist.Distribution))
 
 
     def testExcludePackage(self):
         dist.exclude(packages=['a'], py_modules=['b'], ext_modules=[self.e2])
 
     def testContents(self):
-        self.failUnless(self.dist.has_contents_for('a'))
+        self.assertTrue(self.dist.has_contents_for('a'))
         self.dist.exclude_package('a')
-        self.failIf(self.dist.has_contents_for('a'))
+        self.assertFalse(self.dist.has_contents_for('a'))
 
-        self.failUnless(self.dist.has_contents_for('b'))
+        self.assertTrue(self.dist.has_contents_for('b'))
         self.dist.exclude_package('b')
-        self.failIf(self.dist.has_contents_for('b'))
+        self.assertFalse(self.dist.has_contents_for('b'))
 
-        self.failUnless(self.dist.has_contents_for('c'))
+        self.assertTrue(self.dist.has_contents_for('c'))
         self.dist.exclude_package('c')
-        self.failIf(self.dist.has_contents_for('c'))
+        self.assertFalse(self.dist.has_contents_for('c'))
 
 
 
         )
 
     def testDefaults(self):
-        self.failIf(
+        self.assertFalse(
             Feature(
                 "test",standard=True,remove='x',available=False
             ).include_by_default()
         )
-        self.failUnless(
+        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.failUnless(
+        self.assertTrue(
             ('with-dwim',None,'include DWIM') in dist.feature_options
         )
-        self.failUnless(
+        self.assertTrue(
             ('without-dwim',None,'exclude DWIM (default)') in dist.feature_options
         )
-        self.failUnless(
+        self.assertTrue(
             ('with-bar',None,'include bar (default)') in dist.feature_options
         )
-        self.failUnless(
+        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.failIf('without-baz' in dist.feature_negopt)
+        self.assertFalse('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.failIf('bar_et' in dist.py_modules)
-        self.failIf('pkg.bar' in dist.packages)
-        self.failUnless('pkg.baz' in dist.packages)
-        self.failUnless('scripts/baz_it' in dist.scripts)
-        self.failUnless(('libfoo','foo/foofoo.c') in dist.libraries)
+        self.assertFalse('bar_et' in dist.py_modules)
+        self.assertFalse('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.failUnless(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'])

setuptools/tests/test_resources.py

         ad.add(Distribution.from_filename("FooPkg-1.2-py2.4.egg"))
 
         # Name is in there now
-        self.failUnless(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.failUnless(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.failUnless(parse_version('1.2') in r)
-        self.failUnless(parse_version('1.1') not in r)
-        self.failUnless('1.2' in r)
-        self.failUnless('1.1' not in r)
-        self.failUnless(foo_dist not in r)
-        self.failUnless(twist11 not in r)
-        self.failUnless(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.failUnless(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.failUnless(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.failIf(d("foo-0.3a4.egg") in r1)
-        self.failIf(d("foo-0.3a1.egg") in r1)
-        self.failIf(d("foo-0.3a4.egg") in r2)
+        self.assertFalse(d("foo-0.3a4.egg") in r1)
+        self.assertFalse(d("foo-0.3a1.egg") in r1)
+        self.assertFalse(d("foo-0.3a4.egg") in r2)
 
-        self.failUnless(d("foo-0.3a2.egg") in r1)
-        self.failUnless(d("foo-0.3a2.egg") in r2)
-        self.failUnless(d("foo-0.3a3.egg") in r2)
-        self.failUnless(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.failUnless(p1<p2, (s1,s2,p1,p2))
+            self.assertTrue(p1<p2, (s1,s2,p1,p2))
 
         c('2.1','2.1.1')
         c('2a1','2b0')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.