mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Remove e assertIs definitions and use correct assert* methods.
This commit is contained in:
parent
4cc80ca921
commit
e3467d5c96
6 changed files with 28 additions and 45 deletions
|
@ -7,12 +7,6 @@ import os
|
||||||
|
|
||||||
class BoolTest(unittest.TestCase):
|
class BoolTest(unittest.TestCase):
|
||||||
|
|
||||||
def assertIs(self, a, b):
|
|
||||||
self.assertTrue(a is b)
|
|
||||||
|
|
||||||
def assertIsNot(self, a, b):
|
|
||||||
self.assertTrue(a is not b)
|
|
||||||
|
|
||||||
def test_subclass(self):
|
def test_subclass(self):
|
||||||
try:
|
try:
|
||||||
class C(bool):
|
class C(bool):
|
||||||
|
|
|
@ -72,9 +72,6 @@ class ComplexTest(unittest.TestCase):
|
||||||
self.assertCloseAbs(x.real, y.real, eps)
|
self.assertCloseAbs(x.real, y.real, eps)
|
||||||
self.assertCloseAbs(x.imag, y.imag, eps)
|
self.assertCloseAbs(x.imag, y.imag, eps)
|
||||||
|
|
||||||
def assertIs(self, a, b):
|
|
||||||
self.assertTrue(a is b)
|
|
||||||
|
|
||||||
def check_div(self, x, y):
|
def check_div(self, x, y):
|
||||||
"""Compute complex z=x*y, and check that z/x==y and z/y==x."""
|
"""Compute complex z=x*y, and check that z/x==y and z/y==x."""
|
||||||
z = x * y
|
z = x * y
|
||||||
|
|
|
@ -5,9 +5,6 @@ import genericpath
|
||||||
|
|
||||||
class AllCommonTest(unittest.TestCase):
|
class AllCommonTest(unittest.TestCase):
|
||||||
|
|
||||||
def assertIs(self, a, b):
|
|
||||||
self.assertTrue(a is b)
|
|
||||||
|
|
||||||
def test_commonprefix(self):
|
def test_commonprefix(self):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
genericpath.commonprefix([]),
|
genericpath.commonprefix([]),
|
||||||
|
@ -50,8 +47,8 @@ class AllCommonTest(unittest.TestCase):
|
||||||
f.close()
|
f.close()
|
||||||
self.assertEqual(d, "foobar")
|
self.assertEqual(d, "foobar")
|
||||||
|
|
||||||
self.assertTrue(
|
self.assertLessEqual(
|
||||||
genericpath.getctime(test_support.TESTFN) <=
|
genericpath.getctime(test_support.TESTFN),
|
||||||
genericpath.getmtime(test_support.TESTFN)
|
genericpath.getmtime(test_support.TESTFN)
|
||||||
)
|
)
|
||||||
finally:
|
finally:
|
||||||
|
|
|
@ -6,7 +6,7 @@ import unittest
|
||||||
class MacPathTestCase(unittest.TestCase):
|
class MacPathTestCase(unittest.TestCase):
|
||||||
|
|
||||||
def test_abspath(self):
|
def test_abspath(self):
|
||||||
self.assertTrue(macpath.abspath("xx:yy") == "xx:yy")
|
self.assertEqual(macpath.abspath("xx:yy"), "xx:yy")
|
||||||
|
|
||||||
# Issue 3426: check that abspath retuns unicode when the arg is unicode
|
# Issue 3426: check that abspath retuns unicode when the arg is unicode
|
||||||
# and str when it's str, with both ASCII and non-ASCII cwds
|
# and str when it's str, with both ASCII and non-ASCII cwds
|
||||||
|
@ -31,38 +31,38 @@ class MacPathTestCase(unittest.TestCase):
|
||||||
|
|
||||||
def test_commonprefix(self):
|
def test_commonprefix(self):
|
||||||
commonprefix = macpath.commonprefix
|
commonprefix = macpath.commonprefix
|
||||||
self.assertTrue(commonprefix(["home:swenson:spam", "home:swen:spam"])
|
self.assertEqual(commonprefix(["home:swenson:spam", "home:swen:spam"]),
|
||||||
== "home:swen")
|
"home:swen")
|
||||||
self.assertTrue(commonprefix([":home:swen:spam", ":home:swen:eggs"])
|
self.assertEqual(commonprefix([":home:swen:spam", ":home:swen:eggs"]),
|
||||||
== ":home:swen:")
|
":home:swen:")
|
||||||
self.assertTrue(commonprefix([":home:swen:spam", ":home:swen:spam"])
|
self.assertEqual(commonprefix([":home:swen:spam", ":home:swen:spam"]),
|
||||||
== ":home:swen:spam")
|
":home:swen:spam")
|
||||||
|
|
||||||
def test_split(self):
|
def test_split(self):
|
||||||
split = macpath.split
|
split = macpath.split
|
||||||
self.assertEquals(split("foo:bar"),
|
self.assertEqual(split("foo:bar"),
|
||||||
('foo:', 'bar'))
|
('foo:', 'bar'))
|
||||||
self.assertEquals(split("conky:mountpoint:foo:bar"),
|
self.assertEqual(split("conky:mountpoint:foo:bar"),
|
||||||
('conky:mountpoint:foo', 'bar'))
|
('conky:mountpoint:foo', 'bar'))
|
||||||
|
|
||||||
self.assertEquals(split(":"), ('', ''))
|
self.assertEqual(split(":"), ('', ''))
|
||||||
self.assertEquals(split(":conky:mountpoint:"),
|
self.assertEqual(split(":conky:mountpoint:"),
|
||||||
(':conky:mountpoint', ''))
|
(':conky:mountpoint', ''))
|
||||||
|
|
||||||
def test_splitdrive(self):
|
def test_splitdrive(self):
|
||||||
splitdrive = macpath.splitdrive
|
splitdrive = macpath.splitdrive
|
||||||
self.assertEquals(splitdrive("foo:bar"), ('', 'foo:bar'))
|
self.assertEqual(splitdrive("foo:bar"), ('', 'foo:bar'))
|
||||||
self.assertEquals(splitdrive(":foo:bar"), ('', ':foo:bar'))
|
self.assertEqual(splitdrive(":foo:bar"), ('', ':foo:bar'))
|
||||||
|
|
||||||
def test_splitext(self):
|
def test_splitext(self):
|
||||||
splitext = macpath.splitext
|
splitext = macpath.splitext
|
||||||
self.assertEquals(splitext(":foo.ext"), (':foo', '.ext'))
|
self.assertEqual(splitext(":foo.ext"), (':foo', '.ext'))
|
||||||
self.assertEquals(splitext("foo:foo.ext"), ('foo:foo', '.ext'))
|
self.assertEqual(splitext("foo:foo.ext"), ('foo:foo', '.ext'))
|
||||||
self.assertEquals(splitext(".ext"), ('.ext', ''))
|
self.assertEqual(splitext(".ext"), ('.ext', ''))
|
||||||
self.assertEquals(splitext("foo.ext:foo"), ('foo.ext:foo', ''))
|
self.assertEqual(splitext("foo.ext:foo"), ('foo.ext:foo', ''))
|
||||||
self.assertEquals(splitext(":foo.ext:"), (':foo.ext:', ''))
|
self.assertEqual(splitext(":foo.ext:"), (':foo.ext:', ''))
|
||||||
self.assertEquals(splitext(""), ('', ''))
|
self.assertEqual(splitext(""), ('', ''))
|
||||||
self.assertEquals(splitext("foo.bar.ext"), ('foo.bar', '.ext'))
|
self.assertEqual(splitext("foo.bar.ext"), ('foo.bar', '.ext'))
|
||||||
|
|
||||||
|
|
||||||
def test_main():
|
def test_main():
|
||||||
|
|
|
@ -25,9 +25,6 @@ class PosixPathTest(unittest.TestCase):
|
||||||
test_support.unlink(test_support.TESTFN + suffix)
|
test_support.unlink(test_support.TESTFN + suffix)
|
||||||
safe_rmdir(test_support.TESTFN + suffix)
|
safe_rmdir(test_support.TESTFN + suffix)
|
||||||
|
|
||||||
def assertIs(self, a, b):
|
|
||||||
self.assertTrue(a is b)
|
|
||||||
|
|
||||||
def test_normcase(self):
|
def test_normcase(self):
|
||||||
# Check that normcase() is idempotent
|
# Check that normcase() is idempotent
|
||||||
p = "FoO/./BaR"
|
p = "FoO/./BaR"
|
||||||
|
@ -158,8 +155,8 @@ class PosixPathTest(unittest.TestCase):
|
||||||
f.close()
|
f.close()
|
||||||
self.assertEqual(d, "foobar")
|
self.assertEqual(d, "foobar")
|
||||||
|
|
||||||
self.assertTrue(
|
self.assertLessEqual(
|
||||||
posixpath.getctime(test_support.TESTFN) <=
|
posixpath.getctime(test_support.TESTFN),
|
||||||
posixpath.getmtime(test_support.TESTFN)
|
posixpath.getmtime(test_support.TESTFN)
|
||||||
)
|
)
|
||||||
finally:
|
finally:
|
||||||
|
@ -384,7 +381,7 @@ class PosixPathTest(unittest.TestCase):
|
||||||
self.assertRaises(TypeError, posixpath.normpath)
|
self.assertRaises(TypeError, posixpath.normpath)
|
||||||
|
|
||||||
def test_abspath(self):
|
def test_abspath(self):
|
||||||
self.assertTrue("foo" in posixpath.abspath("foo"))
|
self.assertIn("foo", posixpath.abspath("foo"))
|
||||||
|
|
||||||
# Issue 3426: check that abspath retuns unicode when the arg is unicode
|
# Issue 3426: check that abspath retuns unicode when the arg is unicode
|
||||||
# and str when it's str, with both ASCII and non-ASCII cwds
|
# and str when it's str, with both ASCII and non-ASCII cwds
|
||||||
|
@ -398,7 +395,7 @@ class PosixPathTest(unittest.TestCase):
|
||||||
self.assertRaises(TypeError, posixpath.abspath)
|
self.assertRaises(TypeError, posixpath.abspath)
|
||||||
|
|
||||||
def test_realpath(self):
|
def test_realpath(self):
|
||||||
self.assertTrue("foo" in realpath("foo"))
|
self.assertIn("foo", realpath("foo"))
|
||||||
self.assertRaises(TypeError, posixpath.realpath)
|
self.assertRaises(TypeError, posixpath.realpath)
|
||||||
|
|
||||||
if hasattr(os, "symlink"):
|
if hasattr(os, "symlink"):
|
||||||
|
@ -470,7 +467,8 @@ class PosixPathTest(unittest.TestCase):
|
||||||
self.assertEqual(realpath(ABSTFN + "/link-y/.."), ABSTFN + "/k")
|
self.assertEqual(realpath(ABSTFN + "/link-y/.."), ABSTFN + "/k")
|
||||||
# Relative path.
|
# Relative path.
|
||||||
os.chdir(dirname(ABSTFN))
|
os.chdir(dirname(ABSTFN))
|
||||||
self.assertEqual(realpath(basename(ABSTFN) + "/link-y/.."), ABSTFN + "/k")
|
self.assertEqual(realpath(basename(ABSTFN) + "/link-y/.."),
|
||||||
|
ABSTFN + "/k")
|
||||||
finally:
|
finally:
|
||||||
os.chdir(old_path)
|
os.chdir(old_path)
|
||||||
test_support.unlink(ABSTFN + "/link-y")
|
test_support.unlink(ABSTFN + "/link-y")
|
||||||
|
|
|
@ -281,9 +281,6 @@ class DictTest(unittest.TestCase):
|
||||||
|
|
||||||
class ListTest(unittest.TestCase):
|
class ListTest(unittest.TestCase):
|
||||||
|
|
||||||
def assertIs(self, a, b):
|
|
||||||
self.assertTrue(a is b)
|
|
||||||
|
|
||||||
def test_coverage(self):
|
def test_coverage(self):
|
||||||
# exercise all comparisons for lists
|
# exercise all comparisons for lists
|
||||||
x = [42]
|
x = [42]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue