summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-10-16 18:12:55 (GMT)
committerGuido van Rossum <guido@python.org>2007-10-16 18:12:55 (GMT)
commit3172c5d263eeffff1e89d03d79be3ccc1d60fbde (patch)
treea35e103b36b684c4682ded57236199d6a0ecee4b /Lib/test
parent60d241f135f10312f5a638846659d7e471f6cac9 (diff)
downloadcpython-3172c5d263eeffff1e89d03d79be3ccc1d60fbde.zip
cpython-3172c5d263eeffff1e89d03d79be3ccc1d60fbde.tar.gz
cpython-3172c5d263eeffff1e89d03d79be3ccc1d60fbde.tar.bz2
Patch# 1258 by Christian Heimes: kill basestring.
I like this because it makes the code shorter! :-)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test___future__.py2
-rw-r--r--Lib/test/test_abc.py4
-rw-r--r--Lib/test/test_ast.py2
-rw-r--r--Lib/test/test_codeccallbacks.py6
-rw-r--r--Lib/test/test_codecs.py5
-rw-r--r--Lib/test/test_collections.py4
-rwxr-xr-xLib/test/test_grp.py4
-rw-r--r--Lib/test/test_isinstance.py2
-rw-r--r--Lib/test/test_posixpath.py6
-rw-r--r--Lib/test/test_pwd.py10
-rw-r--r--Lib/test/test_re.py7
-rw-r--r--Lib/test/test_support.py2
-rw-r--r--Lib/test/test_sys.py14
-rw-r--r--Lib/test/test_tempfile.py6
-rw-r--r--Lib/test/test_textwrap.py2
-rw-r--r--Lib/test/test_unittest.py4
16 files changed, 42 insertions, 38 deletions
diff --git a/Lib/test/test___future__.py b/Lib/test/test___future__.py
index 50a2c74..9504155 100644
--- a/Lib/test/test___future__.py
+++ b/Lib/test/test___future__.py
@@ -39,7 +39,7 @@ class FutureTest(unittest.TestCase):
a(isinstance(major, int), "%s major isn't int" % name)
a(isinstance(minor, int), "%s minor isn't int" % name)
a(isinstance(micro, int), "%s micro isn't int" % name)
- a(isinstance(level, basestring),
+ a(isinstance(level, str),
"%s level isn't string" % name)
a(level in GOOD_SERIALS,
"%s level string has unknown value" % name)
diff --git a/Lib/test/test_abc.py b/Lib/test/test_abc.py
index 008d839..e6c8415 100644
--- a/Lib/test/test_abc.py
+++ b/Lib/test/test_abc.py
@@ -81,9 +81,11 @@ class TestABC(unittest.TestCase):
self.assertEqual(issubclass(int, A), True)
class B(A):
pass
- B.register(basestring)
+ B.register(str)
+ class C(str): pass
self.assertEqual(isinstance("", A), True)
self.assertEqual(issubclass(str, A), True)
+ self.assertEqual(issubclass(C, A), True)
def test_registration_edge_cases(self):
class A(metaclass=abc.ABCMeta):
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py
index 6299123..4883ed5 100644
--- a/Lib/test/test_ast.py
+++ b/Lib/test/test_ast.py
@@ -2,7 +2,7 @@ import sys, itertools
import _ast
def to_tuple(t):
- if t is None or isinstance(t, (basestring, int, int, complex)):
+ if t is None or isinstance(t, (str, int, complex)):
return t
elif isinstance(t, list):
return [to_tuple(e) for e in t]
diff --git a/Lib/test/test_codeccallbacks.py b/Lib/test/test_codeccallbacks.py
index 6d7e98e..eedd48a 100644
--- a/Lib/test/test_codeccallbacks.py
+++ b/Lib/test/test_codeccallbacks.py
@@ -140,17 +140,17 @@ class CodecCallbackTest(unittest.TestCase):
sin += chr(sys.maxunicode)
sout = b"a\\xac\\u1234\\u20ac\\u8000"
if sys.maxunicode > 0xffff:
- sout += bytes("\\U%08x" % sys.maxunicode)
+ sout += bytes("\\U%08x" % sys.maxunicode, "ascii")
self.assertEqual(sin.encode("ascii", "backslashreplace"), sout)
sout = b"a\xac\\u1234\\u20ac\\u8000"
if sys.maxunicode > 0xffff:
- sout += bytes("\\U%08x" % sys.maxunicode)
+ sout += bytes("\\U%08x" % sys.maxunicode, "ascii")
self.assertEqual(sin.encode("latin-1", "backslashreplace"), sout)
sout = b"a\xac\\u1234\xa4\\u8000"
if sys.maxunicode > 0xffff:
- sout += bytes("\\U%08x" % sys.maxunicode)
+ sout += bytes("\\U%08x" % sys.maxunicode, "ascii")
self.assertEqual(sin.encode("iso-8859-15", "backslashreplace"), sout)
def test_decoderelaxedutf8(self):
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
index 2d531d2..22db2ca 100644
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -803,8 +803,9 @@ class UnicodeInternalTest(unittest.TestCase):
codecs.register_error("UnicodeInternalTest", codecs.ignore_errors)
decoder = codecs.getdecoder("unicode_internal")
ab = "ab".encode("unicode_internal")
- ignored = decoder(bytes("%s\x22\x22\x22\x22%s" % (ab[:4], ab[4:])),
- "UnicodeInternalTest")
+ ignored = decoder(bytes("%s\x22\x22\x22\x22%s" % (ab[:4], ab[4:]),
+ "ascii"),
+ "UnicodeInternalTest")
self.assertEquals(("ab", 12), ignored)
# From http://www.gnu.org/software/libidn/draft-josefsson-idn-test-vectors.html
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py
index 24266ed..568e682 100644
--- a/Lib/test/test_collections.py
+++ b/Lib/test/test_collections.py
@@ -235,7 +235,7 @@ class TestCollectionABCs(unittest.TestCase):
for sample in [tuple, list, bytes, str]:
self.failUnless(isinstance(sample(), Sequence))
self.failUnless(issubclass(sample, Sequence))
- self.failUnless(issubclass(basestring, Sequence))
+ self.failUnless(issubclass(str, Sequence))
def test_MutableSequence(self):
for sample in [tuple, str]:
@@ -244,7 +244,7 @@ class TestCollectionABCs(unittest.TestCase):
for sample in [list, bytes]:
self.failUnless(isinstance(sample(), MutableSequence))
self.failUnless(issubclass(sample, MutableSequence))
- self.failIf(issubclass(basestring, MutableSequence))
+ self.failIf(issubclass(str, MutableSequence))
def test_main(verbose=None):
diff --git a/Lib/test/test_grp.py b/Lib/test/test_grp.py
index 978dee9..24b3f00 100755
--- a/Lib/test/test_grp.py
+++ b/Lib/test/test_grp.py
@@ -11,9 +11,9 @@ class GroupDatabaseTestCase(unittest.TestCase):
# attributes promised by the docs
self.assertEqual(len(value), 4)
self.assertEqual(value[0], value.gr_name)
- self.assert_(isinstance(value.gr_name, basestring))
+ self.assert_(isinstance(value.gr_name, str))
self.assertEqual(value[1], value.gr_passwd)
- self.assert_(isinstance(value.gr_passwd, basestring))
+ self.assert_(isinstance(value.gr_passwd, str))
self.assertEqual(value[2], value.gr_gid)
self.assert_(isinstance(value.gr_gid, int))
self.assertEqual(value[3], value.gr_mem)
diff --git a/Lib/test/test_isinstance.py b/Lib/test/test_isinstance.py
index c10fd32..1e29f4c 100644
--- a/Lib/test/test_isinstance.py
+++ b/Lib/test/test_isinstance.py
@@ -242,7 +242,7 @@ class TestIsInstanceIsSubclass(unittest.TestCase):
self.assertEqual(True, issubclass(NewSuper, (NewChild, (NewSuper,))))
self.assertEqual(True, issubclass(int, (int, (float, int))))
- self.assertEqual(True, issubclass(str, (str, (Child, NewChild, basestring))))
+ self.assertEqual(True, issubclass(str, (str, (Child, NewChild, str))))
def test_subclass_recursion_limit(self):
# make sure that issubclass raises RuntimeError before the C stack is
diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py
index 3eb981d..8c0d5ff 100644
--- a/Lib/test/test_posixpath.py
+++ b/Lib/test/test_posixpath.py
@@ -335,15 +335,15 @@ class PosixPathTest(unittest.TestCase):
except ImportError:
pass
else:
- self.assert_(isinstance(posixpath.expanduser("~/"), basestring))
+ self.assert_(isinstance(posixpath.expanduser("~/"), str))
# if home directory == root directory, this test makes no sense
if posixpath.expanduser("~") != '/':
self.assertEqual(
posixpath.expanduser("~") + "/",
posixpath.expanduser("~/")
)
- self.assert_(isinstance(posixpath.expanduser("~root/"), basestring))
- self.assert_(isinstance(posixpath.expanduser("~foo/"), basestring))
+ self.assert_(isinstance(posixpath.expanduser("~root/"), str))
+ self.assert_(isinstance(posixpath.expanduser("~foo/"), str))
self.assertRaises(TypeError, posixpath.expanduser)
diff --git a/Lib/test/test_pwd.py b/Lib/test/test_pwd.py
index 7abf905..358b8b3 100644
--- a/Lib/test/test_pwd.py
+++ b/Lib/test/test_pwd.py
@@ -13,19 +13,19 @@ class PwdTest(unittest.TestCase):
for e in entries:
self.assertEqual(len(e), 7)
self.assertEqual(e[0], e.pw_name)
- self.assert_(isinstance(e.pw_name, basestring))
+ self.assert_(isinstance(e.pw_name, str))
self.assertEqual(e[1], e.pw_passwd)
- self.assert_(isinstance(e.pw_passwd, basestring))
+ self.assert_(isinstance(e.pw_passwd, str))
self.assertEqual(e[2], e.pw_uid)
self.assert_(isinstance(e.pw_uid, int))
self.assertEqual(e[3], e.pw_gid)
self.assert_(isinstance(e.pw_gid, int))
self.assertEqual(e[4], e.pw_gecos)
- self.assert_(isinstance(e.pw_gecos, basestring))
+ self.assert_(isinstance(e.pw_gecos, str))
self.assertEqual(e[5], e.pw_dir)
- self.assert_(isinstance(e.pw_dir, basestring))
+ self.assert_(isinstance(e.pw_dir, str))
self.assertEqual(e[6], e.pw_shell)
- self.assert_(isinstance(e.pw_shell, basestring))
+ self.assert_(isinstance(e.pw_shell, str))
# The following won't work, because of duplicate entries
# for one uid
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index 1ede133..f935e1d 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -591,9 +591,10 @@ class ReTests(unittest.TestCase):
self.assertEqual([item.group(0) for item in iter],
[":", "::", ":::"])
- def test_bug_926075(self):
- self.assert_(re.compile('bug_926075') is not
- re.compile(str8('bug_926075')))
+ # XXX This needs to be restored for str vs. bytes.
+## def test_bug_926075(self):
+## self.assert_(re.compile('bug_926075') is not
+## re.compile(str8('bug_926075')))
def test_bug_931848(self):
pattern = eval('"[\u002E\u3002\uFF0E\uFF61]"')
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py
index 5b2176e..fb634f6 100644
--- a/Lib/test/test_support.py
+++ b/Lib/test/test_support.py
@@ -529,7 +529,7 @@ def run_unittest(*classes):
valid_types = (unittest.TestSuite, unittest.TestCase)
suite = unittest.TestSuite()
for cls in classes:
- if isinstance(cls, basestring):
+ if isinstance(cls, str):
if cls in sys.modules:
suite.addTest(unittest.findTestCases(sys.modules[cls]))
else:
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
index e737047..ddf1876 100644
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -126,7 +126,7 @@ class SysModuleTest(unittest.TestCase):
def test_getdefaultencoding(self):
self.assertRaises(TypeError, sys.getdefaultencoding, 42)
# can't check more than the type, as the user might have changed it
- self.assert_(isinstance(sys.getdefaultencoding(), basestring))
+ self.assert_(isinstance(sys.getdefaultencoding(), str))
# testing sys.settrace() is done in test_trace.py
# testing sys.setprofile() is done in test_profile.py
@@ -275,15 +275,15 @@ class SysModuleTest(unittest.TestCase):
self.assert_(isinstance(sys.argv, list))
self.assert_(sys.byteorder in ("little", "big"))
self.assert_(isinstance(sys.builtin_module_names, tuple))
- self.assert_(isinstance(sys.copyright, basestring))
- self.assert_(isinstance(sys.exec_prefix, basestring))
- self.assert_(isinstance(sys.executable, basestring))
+ self.assert_(isinstance(sys.copyright, str))
+ self.assert_(isinstance(sys.exec_prefix, str))
+ self.assert_(isinstance(sys.executable, str))
self.assert_(isinstance(sys.hexversion, int))
self.assert_(isinstance(sys.maxint, int))
self.assert_(isinstance(sys.maxunicode, int))
- self.assert_(isinstance(sys.platform, basestring))
- self.assert_(isinstance(sys.prefix, basestring))
- self.assert_(isinstance(sys.version, basestring))
+ self.assert_(isinstance(sys.platform, str))
+ self.assert_(isinstance(sys.prefix, str))
+ self.assert_(isinstance(sys.version, str))
vi = sys.version_info
self.assert_(isinstance(vi, tuple))
self.assertEqual(len(vi), 5)
diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py
index 3e4f803..8d91927 100644
--- a/Lib/test/test_tempfile.py
+++ b/Lib/test/test_tempfile.py
@@ -143,7 +143,7 @@ class test__candidate_tempdir_list(TC):
self.failIf(len(cand) == 0)
for c in cand:
- self.assert_(isinstance(c, basestring),
+ self.assert_(isinstance(c, str),
"%s is not a string" % c)
def test_wanted_dirs(self):
@@ -328,7 +328,7 @@ class test_gettempprefix(TC):
# gettempprefix returns a nonempty prefix string
p = tempfile.gettempprefix()
- self.assert_(isinstance(p, basestring))
+ self.assert_(isinstance(p, str))
self.assert_(len(p) > 0)
def test_usable_template(self):
@@ -463,7 +463,7 @@ class test_mkdtemp(TC):
extant[i] = self.do_create(pre="aa")
finally:
for i in extant:
- if(isinstance(i, basestring)):
+ if(isinstance(i, str)):
os.rmdir(i)
def test_choose_directory(self):
diff --git a/Lib/test/test_textwrap.py b/Lib/test/test_textwrap.py
index 89316bc..b226c71 100644
--- a/Lib/test/test_textwrap.py
+++ b/Lib/test/test_textwrap.py
@@ -23,7 +23,7 @@ class BaseTestCase(unittest.TestCase):
for i in range(len(textin)):
result.append(" %d: %r" % (i, textin[i]))
result = '\n'.join(result)
- elif isinstance(textin, basestring):
+ elif isinstance(textin, str):
result = " %s\n" % repr(textin)
return result
diff --git a/Lib/test/test_unittest.py b/Lib/test/test_unittest.py
index 9b43f45..eac8074 100644
--- a/Lib/test/test_unittest.py
+++ b/Lib/test/test_unittest.py
@@ -1718,7 +1718,7 @@ class Test_FunctionTestCase(TestCase):
def test_id(self):
test = unittest.FunctionTestCase(lambda: None)
- self.failUnless(isinstance(test.id(), basestring))
+ self.failUnless(isinstance(test.id(), str))
# "Returns a one-line description of the test, or None if no description
# has been provided. The default implementation of this method returns
@@ -2239,7 +2239,7 @@ class Test_TestCase(TestCase, TestEquality, TestHashing):
def runTest(self):
pass
- self.failUnless(isinstance(Foo().id(), basestring))
+ self.failUnless(isinstance(Foo().id(), str))
# "Returns a one-line description of the test, or None if no description
# has been provided. The default implementation of this method returns