mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
convert usage of fail* to assert*
This commit is contained in:
parent
be96cf608f
commit
5c8da86f3a
268 changed files with 5017 additions and 5017 deletions
|
@ -64,9 +64,9 @@ class TestsWithSourceFile(unittest.TestCase):
|
|||
lines = directory.splitlines()
|
||||
self.assertEquals(len(lines), 4) # Number of files + header
|
||||
|
||||
self.assert_('File Name' in lines[0])
|
||||
self.assert_('Modified' in lines[0])
|
||||
self.assert_('Size' in lines[0])
|
||||
self.assertTrue('File Name' in lines[0])
|
||||
self.assertTrue('Modified' in lines[0])
|
||||
self.assertTrue('Size' in lines[0])
|
||||
|
||||
fn, date, time, size = lines[1].split()
|
||||
self.assertEquals(fn, 'another.name')
|
||||
|
@ -76,17 +76,17 @@ class TestsWithSourceFile(unittest.TestCase):
|
|||
# Check the namelist
|
||||
names = zipfp.namelist()
|
||||
self.assertEquals(len(names), 3)
|
||||
self.assert_(TESTFN in names)
|
||||
self.assert_("another"+os.extsep+"name" in names)
|
||||
self.assert_("strfile" in names)
|
||||
self.assertTrue(TESTFN in names)
|
||||
self.assertTrue("another"+os.extsep+"name" in names)
|
||||
self.assertTrue("strfile" in names)
|
||||
|
||||
# Check infolist
|
||||
infos = zipfp.infolist()
|
||||
names = [ i.filename for i in infos ]
|
||||
self.assertEquals(len(names), 3)
|
||||
self.assert_(TESTFN in names)
|
||||
self.assert_("another"+os.extsep+"name" in names)
|
||||
self.assert_("strfile" in names)
|
||||
self.assertTrue(TESTFN in names)
|
||||
self.assertTrue("another"+os.extsep+"name" in names)
|
||||
self.assertTrue("strfile" in names)
|
||||
for i in infos:
|
||||
self.assertEquals(i.file_size, len(self.data))
|
||||
|
||||
|
@ -145,11 +145,11 @@ class TestsWithSourceFile(unittest.TestCase):
|
|||
data = ""
|
||||
for info in infos:
|
||||
data += zipfp.open(info).read()
|
||||
self.assert_(data == "foobar" or data == "barfoo")
|
||||
self.assertTrue(data == "foobar" or data == "barfoo")
|
||||
data = ""
|
||||
for info in infos:
|
||||
data += zipfp.read(info)
|
||||
self.assert_(data == "foobar" or data == "barfoo")
|
||||
self.assertTrue(data == "foobar" or data == "barfoo")
|
||||
zipfp.close()
|
||||
|
||||
def zipRandomOpenTest(self, f, compression):
|
||||
|
@ -451,9 +451,9 @@ class TestZip64InSmallFiles(unittest.TestCase):
|
|||
lines = directory.splitlines()
|
||||
self.assertEquals(len(lines), 4) # Number of files + header
|
||||
|
||||
self.assert_('File Name' in lines[0])
|
||||
self.assert_('Modified' in lines[0])
|
||||
self.assert_('Size' in lines[0])
|
||||
self.assertTrue('File Name' in lines[0])
|
||||
self.assertTrue('Modified' in lines[0])
|
||||
self.assertTrue('Size' in lines[0])
|
||||
|
||||
fn, date, time, size = lines[1].split()
|
||||
self.assertEquals(fn, 'another.name')
|
||||
|
@ -463,17 +463,17 @@ class TestZip64InSmallFiles(unittest.TestCase):
|
|||
# Check the namelist
|
||||
names = zipfp.namelist()
|
||||
self.assertEquals(len(names), 3)
|
||||
self.assert_(TESTFN in names)
|
||||
self.assert_("another"+os.extsep+"name" in names)
|
||||
self.assert_("strfile" in names)
|
||||
self.assertTrue(TESTFN in names)
|
||||
self.assertTrue("another"+os.extsep+"name" in names)
|
||||
self.assertTrue("strfile" in names)
|
||||
|
||||
# Check infolist
|
||||
infos = zipfp.infolist()
|
||||
names = [ i.filename for i in infos ]
|
||||
self.assertEquals(len(names), 3)
|
||||
self.assert_(TESTFN in names)
|
||||
self.assert_("another"+os.extsep+"name" in names)
|
||||
self.assert_("strfile" in names)
|
||||
self.assertTrue(TESTFN in names)
|
||||
self.assertTrue("another"+os.extsep+"name" in names)
|
||||
self.assertTrue("strfile" in names)
|
||||
for i in infos:
|
||||
self.assertEquals(i.file_size, len(self.data))
|
||||
|
||||
|
@ -523,8 +523,8 @@ class PyZipFileTests(unittest.TestCase):
|
|||
zipfp.writepy(fn)
|
||||
|
||||
bn = os.path.basename(fn)
|
||||
self.assert_(bn not in zipfp.namelist())
|
||||
self.assert_(bn + 'o' in zipfp.namelist() or bn + 'c' in zipfp.namelist())
|
||||
self.assertTrue(bn not in zipfp.namelist())
|
||||
self.assertTrue(bn + 'o' in zipfp.namelist() or bn + 'c' in zipfp.namelist())
|
||||
zipfp.close()
|
||||
|
||||
|
||||
|
@ -536,8 +536,8 @@ class PyZipFileTests(unittest.TestCase):
|
|||
zipfp.writepy(fn, "testpackage")
|
||||
|
||||
bn = "%s/%s"%("testpackage", os.path.basename(fn))
|
||||
self.assert_(bn not in zipfp.namelist())
|
||||
self.assert_(bn + 'o' in zipfp.namelist() or bn + 'c' in zipfp.namelist())
|
||||
self.assertTrue(bn not in zipfp.namelist())
|
||||
self.assertTrue(bn + 'o' in zipfp.namelist() or bn + 'c' in zipfp.namelist())
|
||||
zipfp.close()
|
||||
|
||||
def testWritePythonPackage(self):
|
||||
|
@ -549,8 +549,8 @@ class PyZipFileTests(unittest.TestCase):
|
|||
|
||||
# Check for a couple of modules at different levels of the hieararchy
|
||||
names = zipfp.namelist()
|
||||
self.assert_('email/__init__.pyo' in names or 'email/__init__.pyc' in names)
|
||||
self.assert_('email/mime/text.pyo' in names or 'email/mime/text.pyc' in names)
|
||||
self.assertTrue('email/__init__.pyo' in names or 'email/__init__.pyc' in names)
|
||||
self.assertTrue('email/mime/text.pyo' in names or 'email/mime/text.pyc' in names)
|
||||
|
||||
def testWritePythonDirectory(self):
|
||||
os.mkdir(TESTFN2)
|
||||
|
@ -571,9 +571,9 @@ class PyZipFileTests(unittest.TestCase):
|
|||
zipfp.writepy(TESTFN2)
|
||||
|
||||
names = zipfp.namelist()
|
||||
self.assert_('mod1.pyc' in names or 'mod1.pyo' in names)
|
||||
self.assert_('mod2.pyc' in names or 'mod2.pyo' in names)
|
||||
self.assert_('mod2.txt' not in names)
|
||||
self.assertTrue('mod1.pyc' in names or 'mod1.pyo' in names)
|
||||
self.assertTrue('mod2.pyc' in names or 'mod2.pyo' in names)
|
||||
self.assertTrue('mod2.txt' not in names)
|
||||
|
||||
finally:
|
||||
shutil.rmtree(TESTFN2)
|
||||
|
@ -611,7 +611,7 @@ class OtherTests(unittest.TestCase):
|
|||
except IOError, (errno, errmsg):
|
||||
self.fail('Could not append data to a non-existent zip file.')
|
||||
|
||||
self.assert_(os.path.exists(TESTFN))
|
||||
self.assertTrue(os.path.exists(TESTFN))
|
||||
|
||||
zf = zipfile.ZipFile(TESTFN, 'r')
|
||||
self.assertEqual(zf.read(filename), content)
|
||||
|
@ -640,19 +640,19 @@ class OtherTests(unittest.TestCase):
|
|||
with open(TESTFN, "w") as fp:
|
||||
fp.write("this is not a legal zip file\n")
|
||||
chk = zipfile.is_zipfile(TESTFN)
|
||||
self.assert_(not chk)
|
||||
self.assertTrue(not chk)
|
||||
# - passing a file object
|
||||
with open(TESTFN, "rb") as fp:
|
||||
chk = zipfile.is_zipfile(fp)
|
||||
self.assert_(not chk)
|
||||
self.assertTrue(not chk)
|
||||
# - passing a file-like object
|
||||
fp = StringIO()
|
||||
fp.write("this is not a legal zip file\n")
|
||||
chk = zipfile.is_zipfile(fp)
|
||||
self.assert_(not chk)
|
||||
self.assertTrue(not chk)
|
||||
fp.seek(0,0)
|
||||
chk = zipfile.is_zipfile(fp)
|
||||
self.assert_(not chk)
|
||||
self.assertTrue(not chk)
|
||||
|
||||
def testIsZipValidFile(self):
|
||||
# This test checks that the is_zipfile function correctly identifies
|
||||
|
@ -663,21 +663,21 @@ class OtherTests(unittest.TestCase):
|
|||
zipf.writestr("foo.txt", "O, for a Muse of Fire!")
|
||||
zipf.close()
|
||||
chk = zipfile.is_zipfile(TESTFN)
|
||||
self.assert_(chk)
|
||||
self.assertTrue(chk)
|
||||
# - passing a file object
|
||||
with open(TESTFN, "rb") as fp:
|
||||
chk = zipfile.is_zipfile(fp)
|
||||
self.assert_(chk)
|
||||
self.assertTrue(chk)
|
||||
fp.seek(0,0)
|
||||
zip_contents = fp.read()
|
||||
# - passing a file-like object
|
||||
fp = StringIO()
|
||||
fp.write(zip_contents)
|
||||
chk = zipfile.is_zipfile(fp)
|
||||
self.assert_(chk)
|
||||
self.assertTrue(chk)
|
||||
fp.seek(0,0)
|
||||
chk = zipfile.is_zipfile(fp)
|
||||
self.assert_(chk)
|
||||
self.assertTrue(chk)
|
||||
|
||||
def testNonExistentFileRaisesIOError(self):
|
||||
# make sure we don't raise an AttributeError when a partially-constructed
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue