summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_sort.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2003-12-17 20:43:33 (GMT)
committerRaymond Hettinger <python@rcn.com>2003-12-17 20:43:33 (GMT)
commit64958a15d7c03efdc3d2eddf247666e18d1fd910 (patch)
treebc135ae082f8635fa858b81f52f141d7ffbd4c78 /Lib/test/test_sort.py
parentdf38ea9c29a431602704c6bd45ca7417225a61c4 (diff)
downloadcpython-64958a15d7c03efdc3d2eddf247666e18d1fd910.zip
cpython-64958a15d7c03efdc3d2eddf247666e18d1fd910.tar.gz
cpython-64958a15d7c03efdc3d2eddf247666e18d1fd910.tar.bz2
Guido grants a Christmas wish:
sorted() becomes a regular function instead of a classmethod.
Diffstat (limited to 'Lib/test/test_sort.py')
-rw-r--r--Lib/test/test_sort.py55
1 files changed, 0 insertions, 55 deletions
diff --git a/Lib/test/test_sort.py b/Lib/test/test_sort.py
index 667c9ce..dedc41c 100644
--- a/Lib/test/test_sort.py
+++ b/Lib/test/test_sort.py
@@ -248,66 +248,11 @@ class TestDecorateSortUndecorate(unittest.TestCase):
copy2.sort(key=lambda x: x[0], reverse=True)
self.assertEqual(data, copy2)
-class TestSorted(unittest.TestCase):
-
- def test_basic(self):
- data = range(100)
- copy = data[:]
- random.shuffle(copy)
- self.assertEqual(data, list.sorted(copy))
- self.assertNotEqual(data, copy)
-
- data.reverse()
- random.shuffle(copy)
- self.assertEqual(data, list.sorted(copy, cmp=lambda x, y: cmp(y,x)))
- self.assertNotEqual(data, copy)
- random.shuffle(copy)
- self.assertEqual(data, list.sorted(copy, key=lambda x: -x))
- self.assertNotEqual(data, copy)
- random.shuffle(copy)
- self.assertEqual(data, list.sorted(copy, reverse=1))
- self.assertNotEqual(data, copy)
-
- def test_inputtypes(self):
- s = 'abracadabra'
- for T in [unicode, list, tuple]:
- self.assertEqual(list.sorted(s), list.sorted(T(s)))
-
- s = ''.join(dict.fromkeys(s).keys()) # unique letters only
- for T in [unicode, set, frozenset, list, tuple, dict.fromkeys]:
- self.assertEqual(list.sorted(s), list.sorted(T(s)))
-
- def test_baddecorator(self):
- data = 'The quick Brown fox Jumped over The lazy Dog'.split()
- self.assertRaises(TypeError, list.sorted, data, None, lambda x,y: 0)
-
- def classmethods(self):
- s = "hello world"
- a = list.sorted(s)
- b = UserList.sorted(s)
- c = [].sorted(s)
- d = UserList().sorted(s)
- class Mylist(list):
- def __new__(cls):
- return UserList()
- e = MyList.sorted(s)
- f = MyList().sorted(s)
- class Myuserlist(UserList):
- def __new__(cls):
- return []
- g = MyList.sorted(s)
- h = MyList().sorted(s)
- self.assert_(a == b == c == d == e == f == g == h)
- self.assert_(b.__class__ == d.__class__ == UserList)
- self.assert_(e.__class__ == f.__class__ == MyList)
- self.assert_(g.__class__ == h.__class__ == Myuserlist)
-
#==============================================================================
def test_main(verbose=None):
test_classes = (
TestDecorateSortUndecorate,
- TestSorted,
TestBugs,
)