summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-03-14 10:23:39 (GMT)
committerGeorg Brandl <georg@python.org>2010-03-14 10:23:39 (GMT)
commit89fad14944b0ad25fd3afc1b183675042b6c6f6e (patch)
tree7f21ec09111d89f00716612ca60794cf775fe85b /Lib/test
parent1a263ad62f11709e16c41f2448421287cde21e27 (diff)
downloadcpython-89fad14944b0ad25fd3afc1b183675042b6c6f6e.zip
cpython-89fad14944b0ad25fd3afc1b183675042b6c6f6e.tar.gz
cpython-89fad14944b0ad25fd3afc1b183675042b6c6f6e.tar.bz2
Merged revisions 78018,78035-78040,78042-78043,78046,78048-78052,78054,78059,78075-78080 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r78018 | georg.brandl | 2010-02-06 11:08:21 +0100 (Sa, 06 Feb 2010) | 1 line #7864: make deprecation notices a bit clearer. ........ r78035 | georg.brandl | 2010-02-06 23:44:17 +0100 (Sa, 06 Feb 2010) | 1 line Fix duplicate import. ........ r78036 | georg.brandl | 2010-02-06 23:49:47 +0100 (Sa, 06 Feb 2010) | 1 line Remove unused import. ........ r78037 | georg.brandl | 2010-02-06 23:59:15 +0100 (Sa, 06 Feb 2010) | 1 line No need to assign the results of expressions used only for side effects. ........ r78038 | georg.brandl | 2010-02-07 00:02:29 +0100 (So, 07 Feb 2010) | 1 line Add a missing import. ........ r78039 | georg.brandl | 2010-02-07 00:06:24 +0100 (So, 07 Feb 2010) | 1 line Add missing imports. ........ r78040 | georg.brandl | 2010-02-07 00:08:00 +0100 (So, 07 Feb 2010) | 1 line Fix a few UnboundLocalErrors in test_long. ........ r78042 | georg.brandl | 2010-02-07 00:12:12 +0100 (So, 07 Feb 2010) | 1 line Add missing import. ........ r78043 | georg.brandl | 2010-02-07 00:12:19 +0100 (So, 07 Feb 2010) | 1 line Remove duplicate test method. ........ r78046 | georg.brandl | 2010-02-07 00:18:00 +0100 (So, 07 Feb 2010) | 1 line Fix various missing import/unbound name errors. ........ r78048 | georg.brandl | 2010-02-07 00:23:45 +0100 (So, 07 Feb 2010) | 1 line We heard you like test failures so we put unbound locals in your test so that you can fail while you fail. ........ r78049 | georg.brandl | 2010-02-07 00:33:33 +0100 (So, 07 Feb 2010) | 1 line Fix import/access for some identifiers. _TestSharedCTypes does not seem to be executed? ........ r78050 | georg.brandl | 2010-02-07 00:34:10 +0100 (So, 07 Feb 2010) | 1 line Fix more unbound locals in code paths that do not seem to be used. ........ r78051 | georg.brandl | 2010-02-07 00:53:52 +0100 (So, 07 Feb 2010) | 1 line Add missing import when running these tests standalone. ........ r78052 | georg.brandl | 2010-02-07 00:54:04 +0100 (So, 07 Feb 2010) | 1 line Add missing import when running these tests standalone. ........ r78054 | georg.brandl | 2010-02-07 00:58:25 +0100 (So, 07 Feb 2010) | 1 line Add missing import. ........ r78059 | georg.brandl | 2010-02-07 12:34:15 +0100 (So, 07 Feb 2010) | 1 line Use "regexp" consistently. ........ r78075 | georg.brandl | 2010-02-07 13:16:12 +0100 (So, 07 Feb 2010) | 1 line Fix another duplicated test method. ........ r78076 | georg.brandl | 2010-02-07 13:19:43 +0100 (So, 07 Feb 2010) | 1 line Fix wrong usage of "except X, Y:". ........ r78077 | georg.brandl | 2010-02-07 13:25:50 +0100 (So, 07 Feb 2010) | 1 line Fix two redefined test methods. ........ r78078 | georg.brandl | 2010-02-07 13:27:06 +0100 (So, 07 Feb 2010) | 1 line Fix a redefined test method. ........ r78079 | georg.brandl | 2010-02-07 13:34:26 +0100 (So, 07 Feb 2010) | 1 line Add a minimal test for fnmatchcase(). ........ r78080 | georg.brandl | 2010-02-07 13:55:12 +0100 (So, 07 Feb 2010) | 1 line Remove duplicate test method. ........
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_csv.py4
-rw-r--r--Lib/test/test_docxmlrpc.py1
-rw-r--r--Lib/test/test_fnmatch.py5
-rw-r--r--Lib/test/test_functools.py23
-rw-r--r--Lib/test/test_long.py2
-rw-r--r--Lib/test/test_minidom.py3
-rw-r--r--Lib/test/test_multiprocessing.py6
-rw-r--r--Lib/test/test_optparse.py2
-rw-r--r--Lib/test/test_pep292.py13
-rw-r--r--Lib/test/test_platform.py6
-rw-r--r--Lib/test/test_posixpath.py2
-rw-r--r--Lib/test/test_richcmp.py12
-rw-r--r--Lib/test/test_ssl.py16
-rw-r--r--Lib/test/test_sysconfig.py1
-rw-r--r--Lib/test/test_tempfile.py2
-rw-r--r--Lib/test/test_threaded_import.py1
-rw-r--r--Lib/test/test_zipimport.py4
17 files changed, 56 insertions, 47 deletions
diff --git a/Lib/test/test_csv.py b/Lib/test/test_csv.py
index 2c4b783..ca67ac6 100644
--- a/Lib/test/test_csv.py
+++ b/Lib/test/test_csv.py
@@ -488,10 +488,10 @@ hammer and saw"
def test_null(self):
self.writerAssertEqual([], '')
- def test_single(self):
+ def test_single_writer(self):
self.writerAssertEqual([['abc']], 'abc\r\n')
- def test_simple(self):
+ def test_simple_writer(self):
self.writerAssertEqual([[1, 2, 'abc', 3, 4]], '1,2,abc,3,4\r\n')
def test_quotes(self):
diff --git a/Lib/test/test_docxmlrpc.py b/Lib/test/test_docxmlrpc.py
index 5306c31..112be46 100644
--- a/Lib/test/test_docxmlrpc.py
+++ b/Lib/test/test_docxmlrpc.py
@@ -4,6 +4,7 @@ import sys
from test import support
import threading
import time
+import socket
import unittest
PORT = None
diff --git a/Lib/test/test_fnmatch.py b/Lib/test/test_fnmatch.py
index 506c679..2b51099 100644
--- a/Lib/test/test_fnmatch.py
+++ b/Lib/test/test_fnmatch.py
@@ -50,6 +50,11 @@ class FnmatchTestCase(unittest.TestCase):
self.assertRaises(TypeError, fnmatchcase, 'test', b'*')
self.assertRaises(TypeError, fnmatchcase, b'test', '*')
+ def test_fnmatchcase(self):
+ check = self.check_match
+ check('AbC', 'abc', 0)
+ check('abc', 'AbC', 0)
+
def test_bytes(self):
self.check_match(b'test', b'te*')
self.check_match(b'test\xff', b'te*\xff')
diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py
index df335e8..ae47dae 100644
--- a/Lib/test/test_functools.py
+++ b/Lib/test/test_functools.py
@@ -45,9 +45,17 @@ class TestPartial(unittest.TestCase):
# attributes should not be writable
if not isinstance(self.thetype, type):
return
- self.assertRaises(TypeError, setattr, p, 'func', map)
- self.assertRaises(TypeError, setattr, p, 'args', (1, 2))
- self.assertRaises(TypeError, setattr, p, 'keywords', dict(a=1, b=2))
+ self.assertRaises(AttributeError, setattr, p, 'func', map)
+ self.assertRaises(AttributeError, setattr, p, 'args', (1, 2))
+ self.assertRaises(AttributeError, setattr, p, 'keywords', dict(a=1, b=2))
+
+ p = self.thetype(hex)
+ try:
+ del p.__dict__
+ except TypeError:
+ pass
+ else:
+ self.fail('partial object allowed __dict__ to be deleted')
def test_argument_checking(self):
self.assertRaises(TypeError, self.thetype) # need at least a func arg
@@ -123,15 +131,6 @@ class TestPartial(unittest.TestCase):
self.assertRaises(ZeroDivisionError, self.thetype(f), 1, 0)
self.assertRaises(ZeroDivisionError, self.thetype(f, y=0), 1)
- def test_attributes(self):
- p = self.thetype(hex)
- try:
- del p.__dict__
- except TypeError:
- pass
- else:
- self.fail('partial object allowed __dict__ to be deleted')
-
def test_weakref(self):
f = self.thetype(int, base=16)
p = proxy(f)
diff --git a/Lib/test/test_long.py b/Lib/test/test_long.py
index b4ab74f..3c6b215 100644
--- a/Lib/test/test_long.py
+++ b/Lib/test/test_long.py
@@ -502,7 +502,7 @@ class LongTest(unittest.TestCase):
self.d = d
assert float(n) / float(d) == value
else:
- raise TypeError("can't deal with %r" % val)
+ raise TypeError("can't deal with %r" % value)
def _cmp__(self, other):
if not isinstance(other, Rat):
diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py
index 606fada..bd20fa1 100644
--- a/Lib/test/test_minidom.py
+++ b/Lib/test/test_minidom.py
@@ -1449,12 +1449,13 @@ class MinidomTest(unittest.TestCase):
self.confirm(len(n1.entities) == len(n2.entities)
and len(n1.notations) == len(n2.notations))
for i in range(len(n1.notations)):
+ # XXX this loop body doesn't seem to be executed?
no1 = n1.notations.item(i)
no2 = n1.notations.item(i)
self.confirm(no1.name == no2.name
and no1.publicId == no2.publicId
and no1.systemId == no2.systemId)
- statck.append((no1, no2))
+ stack.append((no1, no2))
for i in range(len(n1.entities)):
e1 = n1.entities.item(i)
e2 = n2.entities.item(i)
diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py
index 452e192..035860b 100644
--- a/Lib/test/test_multiprocessing.py
+++ b/Lib/test/test_multiprocessing.py
@@ -1600,10 +1600,10 @@ class _TestSharedCTypes(BaseTestCase):
return
x = Value('i', 7, lock=lock)
- y = Value(ctypes.c_double, 1.0/3.0, lock=lock)
+ y = Value(c_double, 1.0/3.0, lock=lock)
foo = Value(_Foo, 3, 2, lock=lock)
- arr = Array('d', list(range(10)), lock=lock)
- string = Array('c', 20, lock=lock)
+ arr = self.Array('d', list(range(10)), lock=lock)
+ string = self.Array('c', 20, lock=lock)
string.value = 'hello'
p = self.Process(target=self._double, args=(x, y, foo, arr, string))
diff --git a/Lib/test/test_optparse.py b/Lib/test/test_optparse.py
index ac33d61..e9cc2de 100644
--- a/Lib/test/test_optparse.py
+++ b/Lib/test/test_optparse.py
@@ -441,7 +441,7 @@ def _check_duration(option, opt, value):
return int(value)
else:
return int(value[:-1]) * _time_units[value[-1]]
- except ValueError as IndexError:
+ except (ValueError, IndexError):
raise OptionValueError(
'option %s: invalid duration: %r' % (opt, value))
diff --git a/Lib/test/test_pep292.py b/Lib/test/test_pep292.py
index ce9b663..8537b25 100644
--- a/Lib/test/test_pep292.py
+++ b/Lib/test/test_pep292.py
@@ -86,13 +86,6 @@ class TestTemplate(unittest.TestCase):
s = Template('$who likes $100')
raises(ValueError, s.substitute, dict(who='tim'))
- def test_delimiter_override(self):
- class PieDelims(Template):
- delimiter = '@'
- s = PieDelims('@who likes to eat a bag of @{what} worth $100')
- self.assertEqual(s.substitute(dict(who='tim', what='ham')),
- 'tim likes to eat a bag of ham worth $100')
-
def test_idpattern_override(self):
class PathPattern(Template):
idpattern = r'[_a-z][._a-z0-9]*'
@@ -183,6 +176,12 @@ class TestTemplate(unittest.TestCase):
raises(ValueError, s.substitute, dict(gift='bud', who='you'))
eq(s.safe_substitute(), 'this &gift is for &{who} &')
+ class PieDelims(Template):
+ delimiter = '@'
+ s = PieDelims('@who likes to eat a bag of @{what} worth $100')
+ self.assertEqual(s.substitute(dict(who='tim', what='ham')),
+ 'tim likes to eat a bag of ham worth $100')
+
def test_main():
from test import support
diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py
index af37185..9875162 100644
--- a/Lib/test/test_platform.py
+++ b/Lib/test/test_platform.py
@@ -175,8 +175,10 @@ class PlatformTest(unittest.TestCase):
if os.path.isdir(sys.executable) and \
os.path.exists(sys.executable+'.exe'):
# Cygwin horror
- executable = executable + '.exe'
- res = platform.libc_ver(sys.executable)
+ executable = sys.executable + '.exe'
+ else:
+ executable = sys.executable
+ res = platform.libc_ver(executable)
def test_parse_release_file(self):
diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py
index be0afd0..7ba95f7 100644
--- a/Lib/test/test_posixpath.py
+++ b/Lib/test/test_posixpath.py
@@ -2,7 +2,7 @@ import unittest
from test import support, test_genericpath
import posixpath, os
-from posixpath import realpath, abspath, join, dirname, basename, relpath
+from posixpath import realpath, abspath, dirname, basename
# An absolute path to a temporary filename for testing. We can't rely on TESTFN
# being an absolute path, so we need this.
diff --git a/Lib/test/test_richcmp.py b/Lib/test/test_richcmp.py
index aec8bf3..f8f3717 100644
--- a/Lib/test/test_richcmp.py
+++ b/Lib/test/test_richcmp.py
@@ -192,12 +192,12 @@ class MiscTest(unittest.TestCase):
def test_misbehavin(self):
class Misb:
- def __lt__(self, other): return 0
- def __gt__(self, other): return 0
- def __eq__(self, other): return 0
- def __le__(self, other): raise TestFailed("This shouldn't happen")
- def __ge__(self, other): raise TestFailed("This shouldn't happen")
- def __ne__(self, other): raise TestFailed("This shouldn't happen")
+ def __lt__(self_, other): return 0
+ def __gt__(self_, other): return 0
+ def __eq__(self_, other): return 0
+ def __le__(self_, other): self.fail("This shouldn't happen")
+ def __ge__(self_, other): self.fail("This shouldn't happen")
+ def __ne__(self_, other): self.fail("This shouldn't happen")
a = Misb()
b = Misb()
self.assertEqual(a<b, 0)
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
index 383c78a..3467e3a 100644
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -1063,9 +1063,9 @@ else:
ssl_version=ssl.PROTOCOL_TLSv1)
s.connect((HOST, server.port))
except ssl.SSLError as x:
- raise support.TestFailed("Unexpected SSL error: " + str(x))
+ self.fail("Unexpected SSL error: " + str(x))
except Exception as x:
- raise support.TestFailed("Unexpected exception: " + str(x))
+ self.fail("Unexpected exception: " + str(x))
else:
# helper methods for standardising recv* method signatures
def _recv_into():
@@ -1099,7 +1099,7 @@ else:
outdata = s.read()
outdata = str(outdata, 'ASCII', 'strict')
if outdata != indata.lower():
- raise support.TestFailed(
+ self.fail(
"While sending with <<{name:s}>> bad data "
"<<{outdata:s}>> ({nout:d}) received; "
"expected <<{indata:s}>> ({nin:d})\n".format(
@@ -1110,12 +1110,12 @@ else:
)
except ValueError as e:
if expect_success:
- raise support.TestFailed(
+ self.fail(
"Failed to send with method <<{name:s}>>; "
"expected to succeed.\n".format(name=meth_name)
)
if not str(e).startswith(meth_name):
- raise support.TestFailed(
+ self.fail(
"Method <<{name:s}>> failed with unexpected "
"exception message: {exp:s}\n".format(
name=meth_name, exp=e
@@ -1129,7 +1129,7 @@ else:
outdata = recv_meth(*args)
outdata = str(outdata, 'ASCII', 'strict')
if outdata != indata.lower():
- raise support.TestFailed(
+ self.fail(
"While receiving with <<{name:s}>> bad data "
"<<{outdata:s}>> ({nout:d}) received; "
"expected <<{indata:s}>> ({nin:d})\n".format(
@@ -1140,12 +1140,12 @@ else:
)
except ValueError as e:
if expect_success:
- raise support.TestFailed(
+ self.fail(
"Failed to receive with method <<{name:s}>>; "
"expected to succeed.\n".format(name=meth_name)
)
if not str(e).startswith(meth_name):
- raise support.TestFailed(
+ self.fail(
"Method <<{name:s}>> failed with unexpected "
"exception message: {exp:s}\n".format(
name=meth_name, exp=e
diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py
index 67057bc..614dffc 100644
--- a/Lib/test/test_sysconfig.py
+++ b/Lib/test/test_sysconfig.py
@@ -9,6 +9,7 @@ import sys
import test
import os
import subprocess
+import shutil
from copy import copy, deepcopy
from test.support import run_unittest, TESTFN, unlink, get_attribute
diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py
index de65158..5b6a420 100644
--- a/Lib/test/test_tempfile.py
+++ b/Lib/test/test_tempfile.py
@@ -127,7 +127,7 @@ class test__RandomNameSequence(TC):
if i == 20:
break
except:
- failOnException("iteration")
+ self.failOnException("iteration")
test_classes.append(test__RandomNameSequence)
diff --git a/Lib/test/test_threaded_import.py b/Lib/test/test_threaded_import.py
index af9e89d..29eab1a 100644
--- a/Lib/test/test_threaded_import.py
+++ b/Lib/test/test_threaded_import.py
@@ -6,6 +6,7 @@
# randrange, and then Python hangs.
import _thread as thread
+import unittest
from test.support import verbose, TestFailed
critical_section = thread.allocate_lock()
diff --git a/Lib/test/test_zipimport.py b/Lib/test/test_zipimport.py
index 0233934..c89aef5 100644
--- a/Lib/test/test_zipimport.py
+++ b/Lib/test/test_zipimport.py
@@ -227,7 +227,7 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
mod_path = packdir2 + TESTMOD
mod_name = module_path_to_dotted_name(mod_path)
- pkg = __import__(mod_name)
+ __import__(mod_name)
mod = sys.modules[mod_name]
self.assertEquals(zi.get_source(TESTPACK), None)
self.assertEquals(zi.get_source(mod_path), None)
@@ -271,7 +271,7 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
mod_path = TESTPACK2 + os.sep + TESTMOD
mod_name = module_path_to_dotted_name(mod_path)
- pkg = __import__(mod_name)
+ __import__(mod_name)
mod = sys.modules[mod_name]
self.assertEquals(zi.get_source(TESTPACK2), None)
self.assertEquals(zi.get_source(mod_path), None)