summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_builtin.py
diff options
context:
space:
mode:
authorEric Smith <eric@trueblade.com>2008-02-21 20:17:08 (GMT)
committerEric Smith <eric@trueblade.com>2008-02-21 20:17:08 (GMT)
commitce584d420d012b7bc3998ad0fb055c464ad58e37 (patch)
treea07ca4f7aface1d0526038503544cda407975e21 /Lib/test/test_builtin.py
parentaf16ece18e420d110ae7ef4d44fe34181de5199f (diff)
downloadcpython-ce584d420d012b7bc3998ad0fb055c464ad58e37.zip
cpython-ce584d420d012b7bc3998ad0fb055c464ad58e37.tar.gz
cpython-ce584d420d012b7bc3998ad0fb055c464ad58e37.tar.bz2
Moved test_format into the correct TestCase.
Diffstat (limited to 'Lib/test/test_builtin.py')
-rw-r--r--Lib/test/test_builtin.py78
1 files changed, 39 insertions, 39 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
index a5d1f92..36b84d8 100644
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -1973,45 +1973,6 @@ class BuiltinTest(unittest.TestCase):
return i
self.assertRaises(ValueError, zip, BadSeq(), BadSeq())
-class TestSorted(unittest.TestCase):
-
- def test_basic(self):
- data = range(100)
- copy = data[:]
- random.shuffle(copy)
- self.assertEqual(data, sorted(copy))
- self.assertNotEqual(data, copy)
-
- data.reverse()
- random.shuffle(copy)
- self.assertEqual(data, sorted(copy, cmp=lambda x, y: cmp(y,x)))
- self.assertNotEqual(data, copy)
- random.shuffle(copy)
- self.assertEqual(data, sorted(copy, key=lambda x: -x))
- self.assertNotEqual(data, copy)
- random.shuffle(copy)
- self.assertEqual(data, sorted(copy, reverse=1))
- self.assertNotEqual(data, copy)
-
- def test_inputtypes(self):
- s = 'abracadabra'
- types = [list, tuple]
- if have_unicode:
- types.insert(0, unicode)
- for T in types:
- self.assertEqual(sorted(s), sorted(T(s)))
-
- s = ''.join(dict.fromkeys(s).keys()) # unique letters only
- types = [set, frozenset, list, tuple, dict.fromkeys]
- if have_unicode:
- types.insert(0, unicode)
- for T in types:
- self.assertEqual(sorted(s), sorted(T(s)))
-
- def test_baddecorator(self):
- data = 'The quick Brown fox Jumped over The lazy Dog'.split()
- self.assertRaises(TypeError, sorted, data, None, lambda x,y: 0)
-
def test_format(self):
# Test the basic machinery of the format() builtin. Don't test
# the specifics of the various formatters
@@ -2107,6 +2068,45 @@ class TestSorted(unittest.TestCase):
class DerivedFromStr(str): pass
self.assertEqual(format(0, DerivedFromStr('10')), ' 0')
+class TestSorted(unittest.TestCase):
+
+ def test_basic(self):
+ data = range(100)
+ copy = data[:]
+ random.shuffle(copy)
+ self.assertEqual(data, sorted(copy))
+ self.assertNotEqual(data, copy)
+
+ data.reverse()
+ random.shuffle(copy)
+ self.assertEqual(data, sorted(copy, cmp=lambda x, y: cmp(y,x)))
+ self.assertNotEqual(data, copy)
+ random.shuffle(copy)
+ self.assertEqual(data, sorted(copy, key=lambda x: -x))
+ self.assertNotEqual(data, copy)
+ random.shuffle(copy)
+ self.assertEqual(data, sorted(copy, reverse=1))
+ self.assertNotEqual(data, copy)
+
+ def test_inputtypes(self):
+ s = 'abracadabra'
+ types = [list, tuple]
+ if have_unicode:
+ types.insert(0, unicode)
+ for T in types:
+ self.assertEqual(sorted(s), sorted(T(s)))
+
+ s = ''.join(dict.fromkeys(s).keys()) # unique letters only
+ types = [set, frozenset, list, tuple, dict.fromkeys]
+ if have_unicode:
+ types.insert(0, unicode)
+ for T in types:
+ self.assertEqual(sorted(s), sorted(T(s)))
+
+ def test_baddecorator(self):
+ data = 'The quick Brown fox Jumped over The lazy Dog'.split()
+ self.assertRaises(TypeError, sorted, data, None, lambda x,y: 0)
+
def test_main(verbose=None):
test_classes = (BuiltinTest, TestSorted)