summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-10-11 00:49:57 (GMT)
committerBenjamin Peterson <benjamin@python.org>2008-10-11 00:49:57 (GMT)
commitf10a79aad4e2fc62d2c3675e89f873b22b185e7b (patch)
tree06b042ca03a71663d26ad95949807d1bd2472bf4 /Lib/test
parent2d8dcdcb06005858e87eded012ceff10920445b7 (diff)
downloadcpython-f10a79aad4e2fc62d2c3675e89f873b22b185e7b.zip
cpython-f10a79aad4e2fc62d2c3675e89f873b22b185e7b.tar.gz
cpython-f10a79aad4e2fc62d2c3675e89f873b22b185e7b.tar.bz2
merge from trunk
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_atexit.py5
-rw-r--r--Lib/test/test_bisect.py11
-rw-r--r--Lib/test/test_datetime.py2
-rw-r--r--Lib/test/test_dbm.py17
-rw-r--r--Lib/test/test_docxmlrpc.py4
-rw-r--r--Lib/test/test_set.py11
6 files changed, 45 insertions, 5 deletions
diff --git a/Lib/test/test_atexit.py b/Lib/test/test_atexit.py
index 04af9fb..8a71036 100644
--- a/Lib/test/test_atexit.py
+++ b/Lib/test/test_atexit.py
@@ -26,12 +26,13 @@ def raise2():
class TestCase(unittest.TestCase):
def setUp(self):
self.stream = io.StringIO()
+ self.save_stdout, self.save_stderr = sys.stderr, sys.stdout
sys.stdout = sys.stderr = self.stream
atexit._clear()
def tearDown(self):
- sys.stdout = sys.__stdout__
- sys.stderr = sys.__stderr__
+ sys.stdout = self.save_stdout
+ sys.stderr = self.save_stderr
atexit._clear()
def test_args(self):
diff --git a/Lib/test/test_bisect.py b/Lib/test/test_bisect.py
index 987f33c..df2f8b1 100644
--- a/Lib/test/test_bisect.py
+++ b/Lib/test/test_bisect.py
@@ -196,6 +196,17 @@ class TestInsort(unittest.TestCase):
def test_backcompatibility(self):
self.assertEqual(self.module.insort, self.module.insort_right)
+ def test_listDerived(self):
+ class List(list):
+ data = []
+ def insert(self, index, item):
+ self.data.insert(index, item)
+
+ lst = List()
+ self.module.insort_left(lst, 10)
+ self.module.insort_right(lst, 5)
+ self.assertEqual([5, 10], lst.data)
+
class TestInsortPython(TestInsort):
module = py_bisect
diff --git a/Lib/test/test_datetime.py b/Lib/test/test_datetime.py
index 4b8ae82..ead4b1c 100644
--- a/Lib/test/test_datetime.py
+++ b/Lib/test/test_datetime.py
@@ -249,7 +249,7 @@ class TestTimeDelta(HarmlessMixedComparison, unittest.TestCase):
self.assertRaises(TypeError, lambda: a // x)
self.assertRaises(TypeError, lambda: x // a)
- # Divison of int by timedelta doesn't make sense.
+ # Division of int by timedelta doesn't make sense.
# Division by zero doesn't make sense.
for zero in 0, 0:
self.assertRaises(TypeError, lambda: zero // a)
diff --git a/Lib/test/test_dbm.py b/Lib/test/test_dbm.py
index ee82dd2..9f929f4 100644
--- a/Lib/test/test_dbm.py
+++ b/Lib/test/test_dbm.py
@@ -140,6 +140,23 @@ class WhichDBTestCase(unittest.TestCase):
def setUp(self):
delete_files()
+ self.filename = test.support.TESTFN
+ self.d = dbm.open(self.filename, 'c')
+ self.d.close()
+
+ def test_keys(self):
+ self.d = dbm.open(self.filename, 'c')
+ self.assertEqual(self.d.keys(), [])
+ a = [(b'a', b'b'), (b'12345678910', b'019237410982340912840198242')]
+ for k, v in a:
+ self.d[k] = v
+ self.assertEqual(sorted(self.d.keys()), sorted(k for (k, v) in a))
+ for k, v in a:
+ self.assert_(k in self.d)
+ self.assertEqual(self.d[k], v)
+ self.assert_('xxx' not in self.d)
+ self.assertRaises(KeyError, lambda: self.d['xxx'])
+ self.d.close()
def test_main():
diff --git a/Lib/test/test_docxmlrpc.py b/Lib/test/test_docxmlrpc.py
index d1799a2..bd96e23 100644
--- a/Lib/test/test_docxmlrpc.py
+++ b/Lib/test/test_docxmlrpc.py
@@ -8,9 +8,9 @@ import unittest
PORT = None
def server(evt, numrequests):
- try:
- serv = DocXMLRPCServer(("localhost", 0), logRequests=False)
+ serv = DocXMLRPCServer(("localhost", 0), logRequests=False)
+ try:
global PORT
PORT = serv.socket.getsockname()[1]
diff --git a/Lib/test/test_set.py b/Lib/test/test_set.py
index 0e92551..0effd65 100644
--- a/Lib/test/test_set.py
+++ b/Lib/test/test_set.py
@@ -391,6 +391,17 @@ class TestSet(TestJointOps):
else:
self.fail()
+ def test_remove_keyerror_set(self):
+ key = self.thetype([3, 4])
+ try:
+ self.s.remove(key)
+ except KeyError as e:
+ self.assert_(e.args[0] is key,
+ "KeyError should be {0}, not {1}".format(key,
+ e.args[0]))
+ else:
+ self.fail()
+
def test_discard(self):
self.s.discard('a')
self.assert_('a' not in self.s)