mirror of https://github.com/python/cpython
Various tests cleanup: check_warnings/check_py3k_warnings, unittest.assert* and setUp/tearDown.
This commit is contained in:
parent
4854c969fb
commit
bc27c6a5aa
|
@ -8,12 +8,9 @@ This should generate Barry's example, modulo some quotes and newlines.
|
|||
"""
|
||||
|
||||
import unittest, StringIO
|
||||
from test.test_support import run_unittest
|
||||
|
||||
import warnings
|
||||
warnings.filterwarnings("ignore", "the MimeWriter module is deprecated.*",
|
||||
DeprecationWarning)
|
||||
from test.test_support import run_unittest, import_module
|
||||
|
||||
import_module("MimeWriter", deprecated=True)
|
||||
from MimeWriter import MimeWriter
|
||||
|
||||
SELLER = '''\
|
||||
|
|
|
@ -841,9 +841,9 @@ class AssortedBytesTest(unittest.TestCase):
|
|||
self.assertEqual(bytes(b"abc") <= b"ab", False)
|
||||
|
||||
def test_doc(self):
|
||||
self.assertTrue(bytearray.__doc__ != None)
|
||||
self.assertIsNotNone(bytearray.__doc__)
|
||||
self.assertTrue(bytearray.__doc__.startswith("bytearray("), bytearray.__doc__)
|
||||
self.assertTrue(bytes.__doc__ != None)
|
||||
self.assertIsNotNone(bytes.__doc__)
|
||||
self.assertTrue(bytes.__doc__.startswith("bytes("), bytes.__doc__)
|
||||
|
||||
def test_from_bytearray(self):
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
# Python test set -- part 1, grammar.
|
||||
# This just tests whether the parser accepts them all.
|
||||
|
||||
# NOTE: When you run this test as a script from the command line, you
|
||||
# get warnings about certain hex/oct constants. Since those are
|
||||
# issued by the parser, you can't suppress them by adding a
|
||||
# filterwarnings() call to this module. Therefore, to shut up the
|
||||
# regression test, the filterwarnings() call has been added to
|
||||
# regrtest.py.
|
||||
|
||||
from test.test_support import run_unittest, check_syntax_error, \
|
||||
check_py3k_warnings
|
||||
import unittest
|
||||
|
@ -15,27 +8,28 @@ import sys
|
|||
# testing import *
|
||||
from sys import *
|
||||
|
||||
|
||||
class TokenTests(unittest.TestCase):
|
||||
|
||||
def testBackslash(self):
|
||||
# Backslash means line continuation:
|
||||
x = 1 \
|
||||
+ 1
|
||||
self.assertEquals(x, 2, 'backslash for line continuation')
|
||||
self.assertEqual(x, 2, 'backslash for line continuation')
|
||||
|
||||
# Backslash does not means continuation in comments :\
|
||||
x = 0
|
||||
self.assertEquals(x, 0, 'backslash ending comment')
|
||||
self.assertEqual(x, 0, 'backslash ending comment')
|
||||
|
||||
def testPlainIntegers(self):
|
||||
self.assertEquals(0xff, 255)
|
||||
self.assertEquals(0377, 255)
|
||||
self.assertEquals(2147483647, 017777777777)
|
||||
self.assertEqual(0xff, 255)
|
||||
self.assertEqual(0377, 255)
|
||||
self.assertEqual(2147483647, 017777777777)
|
||||
# "0x" is not a valid literal
|
||||
self.assertRaises(SyntaxError, eval, "0x")
|
||||
from sys import maxint
|
||||
if maxint == 2147483647:
|
||||
self.assertEquals(-2147483647-1, -020000000000)
|
||||
self.assertEqual(-2147483647-1, -020000000000)
|
||||
# XXX -2147483648
|
||||
self.assertTrue(037777777777 > 0)
|
||||
self.assertTrue(0xffffffff > 0)
|
||||
|
@ -45,7 +39,7 @@ class TokenTests(unittest.TestCase):
|
|||
except OverflowError:
|
||||
self.fail("OverflowError on huge integer literal %r" % s)
|
||||
elif maxint == 9223372036854775807:
|
||||
self.assertEquals(-9223372036854775807-1, -01000000000000000000000)
|
||||
self.assertEqual(-9223372036854775807-1, -01000000000000000000000)
|
||||
self.assertTrue(01777777777777777777777 > 0)
|
||||
self.assertTrue(0xffffffffffffffff > 0)
|
||||
for s in '9223372036854775808', '02000000000000000000000', \
|
||||
|
@ -98,28 +92,28 @@ jumps over
|
|||
the 'lazy' dog.
|
||||
"""
|
||||
y = '\nThe "quick"\nbrown fox\njumps over\nthe \'lazy\' dog.\n'
|
||||
self.assertEquals(x, y)
|
||||
self.assertEqual(x, y)
|
||||
y = '''
|
||||
The "quick"
|
||||
brown fox
|
||||
jumps over
|
||||
the 'lazy' dog.
|
||||
'''
|
||||
self.assertEquals(x, y)
|
||||
self.assertEqual(x, y)
|
||||
y = "\n\
|
||||
The \"quick\"\n\
|
||||
brown fox\n\
|
||||
jumps over\n\
|
||||
the 'lazy' dog.\n\
|
||||
"
|
||||
self.assertEquals(x, y)
|
||||
self.assertEqual(x, y)
|
||||
y = '\n\
|
||||
The \"quick\"\n\
|
||||
brown fox\n\
|
||||
jumps over\n\
|
||||
the \'lazy\' dog.\n\
|
||||
'
|
||||
self.assertEquals(x, y)
|
||||
self.assertEqual(x, y)
|
||||
|
||||
|
||||
class GrammarTests(unittest.TestCase):
|
||||
|
@ -156,18 +150,18 @@ class GrammarTests(unittest.TestCase):
|
|||
# Silence Py3k warning
|
||||
exec('def f4(two, (compound, (argument, list))): pass')
|
||||
exec('def f5((compound, first), two): pass')
|
||||
self.assertEquals(f2.func_code.co_varnames, ('one_argument',))
|
||||
self.assertEquals(f3.func_code.co_varnames, ('two', 'arguments'))
|
||||
self.assertEqual(f2.func_code.co_varnames, ('one_argument',))
|
||||
self.assertEqual(f3.func_code.co_varnames, ('two', 'arguments'))
|
||||
if sys.platform.startswith('java'):
|
||||
self.assertEquals(f4.func_code.co_varnames,
|
||||
self.assertEqual(f4.func_code.co_varnames,
|
||||
('two', '(compound, (argument, list))', 'compound', 'argument',
|
||||
'list',))
|
||||
self.assertEquals(f5.func_code.co_varnames,
|
||||
self.assertEqual(f5.func_code.co_varnames,
|
||||
('(compound, first)', 'two', 'compound', 'first'))
|
||||
else:
|
||||
self.assertEquals(f4.func_code.co_varnames,
|
||||
self.assertEqual(f4.func_code.co_varnames,
|
||||
('two', '.1', 'compound', 'argument', 'list'))
|
||||
self.assertEquals(f5.func_code.co_varnames,
|
||||
self.assertEqual(f5.func_code.co_varnames,
|
||||
('.0', 'two', 'compound', 'first'))
|
||||
def a1(one_arg,): pass
|
||||
def a2(two, args,): pass
|
||||
|
@ -204,10 +198,10 @@ class GrammarTests(unittest.TestCase):
|
|||
# ceval unpacks the formal arguments into the first argcount names;
|
||||
# thus, the names nested inside tuples must appear after these names.
|
||||
if sys.platform.startswith('java'):
|
||||
self.assertEquals(v3.func_code.co_varnames, ('a', '(b, c)', 'rest', 'b', 'c'))
|
||||
self.assertEqual(v3.func_code.co_varnames, ('a', '(b, c)', 'rest', 'b', 'c'))
|
||||
else:
|
||||
self.assertEquals(v3.func_code.co_varnames, ('a', '.1', 'rest', 'b', 'c'))
|
||||
self.assertEquals(v3(1, (2, 3), 4), (1, 2, 3, (4,)))
|
||||
self.assertEqual(v3.func_code.co_varnames, ('a', '.1', 'rest', 'b', 'c'))
|
||||
self.assertEqual(v3(1, (2, 3), 4), (1, 2, 3, (4,)))
|
||||
def d01(a=1): pass
|
||||
d01()
|
||||
d01(1)
|
||||
|
@ -289,7 +283,7 @@ class GrammarTests(unittest.TestCase):
|
|||
# keyword arguments after *arglist
|
||||
def f(*args, **kwargs):
|
||||
return args, kwargs
|
||||
self.assertEquals(f(1, x=2, *[3, 4], y=5), ((1, 3, 4),
|
||||
self.assertEqual(f(1, x=2, *[3, 4], y=5), ((1, 3, 4),
|
||||
{'x':2, 'y':5}))
|
||||
self.assertRaises(SyntaxError, eval, "f(1, *(2,3), 4)")
|
||||
self.assertRaises(SyntaxError, eval, "f(1, x=2, *(3,4), x=5)")
|
||||
|
@ -301,15 +295,15 @@ class GrammarTests(unittest.TestCase):
|
|||
def testLambdef(self):
|
||||
### lambdef: 'lambda' [varargslist] ':' test
|
||||
l1 = lambda : 0
|
||||
self.assertEquals(l1(), 0)
|
||||
self.assertEqual(l1(), 0)
|
||||
l2 = lambda : a[d] # XXX just testing the expression
|
||||
l3 = lambda : [2 < x for x in [-1, 3, 0L]]
|
||||
self.assertEquals(l3(), [0, 1, 0])
|
||||
self.assertEqual(l3(), [0, 1, 0])
|
||||
l4 = lambda x = lambda y = lambda z=1 : z : y() : x()
|
||||
self.assertEquals(l4(), 1)
|
||||
self.assertEqual(l4(), 1)
|
||||
l5 = lambda x, y, z=2: x + y + z
|
||||
self.assertEquals(l5(1, 2), 5)
|
||||
self.assertEquals(l5(1, 2, 3), 6)
|
||||
self.assertEqual(l5(1, 2), 5)
|
||||
self.assertEqual(l5(1, 2, 3), 6)
|
||||
check_syntax_error(self, "lambda x: x = 2")
|
||||
check_syntax_error(self, "lambda (None,): None")
|
||||
|
||||
|
@ -545,8 +539,6 @@ hello world
|
|||
g = {}
|
||||
l = {}
|
||||
|
||||
import warnings
|
||||
warnings.filterwarnings("ignore", "global statement", module="<string>")
|
||||
exec 'global a; a = 1; b = 2' in g, l
|
||||
if '__builtins__' in g: del g['__builtins__']
|
||||
if '__builtins__' in l: del l['__builtins__']
|
||||
|
@ -562,7 +554,7 @@ hello world
|
|||
try:
|
||||
assert 0, "msg"
|
||||
except AssertionError, e:
|
||||
self.assertEquals(e.args[0], "msg")
|
||||
self.assertEqual(e.args[0], "msg")
|
||||
else:
|
||||
if __debug__:
|
||||
self.fail("AssertionError not raised by assert 0")
|
||||
|
@ -596,7 +588,7 @@ hello world
|
|||
x = 1
|
||||
else:
|
||||
x = 2
|
||||
self.assertEquals(x, 2)
|
||||
self.assertEqual(x, 2)
|
||||
|
||||
def testFor(self):
|
||||
# 'for' exprlist 'in' exprlist ':' suite ['else' ':' suite]
|
||||
|
@ -751,7 +743,7 @@ hello world
|
|||
d[1,2,3] = 4
|
||||
L = list(d)
|
||||
L.sort()
|
||||
self.assertEquals(str(L), '[1, (1,), (1, 2), (1, 2, 3)]')
|
||||
self.assertEqual(str(L), '[1, (1,), (1, 2), (1, 2, 3)]')
|
||||
|
||||
def testAtoms(self):
|
||||
### atom: '(' [testlist] ')' | '[' [testlist] ']' | '{' [dictmaker] '}' | '`' testlist '`' | NAME | NUMBER | STRING
|
||||
|
|
|
@ -103,42 +103,42 @@ class BaseHTTPServerTestCase(BaseTestCase):
|
|||
def test_command(self):
|
||||
self.con.request('GET', '/')
|
||||
res = self.con.getresponse()
|
||||
self.assertEquals(res.status, 501)
|
||||
self.assertEqual(res.status, 501)
|
||||
|
||||
def test_request_line_trimming(self):
|
||||
self.con._http_vsn_str = 'HTTP/1.1\n'
|
||||
self.con.putrequest('GET', '/')
|
||||
self.con.endheaders()
|
||||
res = self.con.getresponse()
|
||||
self.assertEquals(res.status, 501)
|
||||
self.assertEqual(res.status, 501)
|
||||
|
||||
def test_version_bogus(self):
|
||||
self.con._http_vsn_str = 'FUBAR'
|
||||
self.con.putrequest('GET', '/')
|
||||
self.con.endheaders()
|
||||
res = self.con.getresponse()
|
||||
self.assertEquals(res.status, 400)
|
||||
self.assertEqual(res.status, 400)
|
||||
|
||||
def test_version_digits(self):
|
||||
self.con._http_vsn_str = 'HTTP/9.9.9'
|
||||
self.con.putrequest('GET', '/')
|
||||
self.con.endheaders()
|
||||
res = self.con.getresponse()
|
||||
self.assertEquals(res.status, 400)
|
||||
self.assertEqual(res.status, 400)
|
||||
|
||||
def test_version_none_get(self):
|
||||
self.con._http_vsn_str = ''
|
||||
self.con.putrequest('GET', '/')
|
||||
self.con.endheaders()
|
||||
res = self.con.getresponse()
|
||||
self.assertEquals(res.status, 501)
|
||||
self.assertEqual(res.status, 501)
|
||||
|
||||
def test_version_none(self):
|
||||
self.con._http_vsn_str = ''
|
||||
self.con.putrequest('PUT', '/')
|
||||
self.con.endheaders()
|
||||
res = self.con.getresponse()
|
||||
self.assertEquals(res.status, 400)
|
||||
self.assertEqual(res.status, 400)
|
||||
|
||||
def test_version_invalid(self):
|
||||
self.con._http_vsn = 99
|
||||
|
@ -146,21 +146,21 @@ class BaseHTTPServerTestCase(BaseTestCase):
|
|||
self.con.putrequest('GET', '/')
|
||||
self.con.endheaders()
|
||||
res = self.con.getresponse()
|
||||
self.assertEquals(res.status, 505)
|
||||
self.assertEqual(res.status, 505)
|
||||
|
||||
def test_send_blank(self):
|
||||
self.con._http_vsn_str = ''
|
||||
self.con.putrequest('', '')
|
||||
self.con.endheaders()
|
||||
res = self.con.getresponse()
|
||||
self.assertEquals(res.status, 400)
|
||||
self.assertEqual(res.status, 400)
|
||||
|
||||
def test_header_close(self):
|
||||
self.con.putrequest('GET', '/')
|
||||
self.con.putheader('Connection', 'close')
|
||||
self.con.endheaders()
|
||||
res = self.con.getresponse()
|
||||
self.assertEquals(res.status, 501)
|
||||
self.assertEqual(res.status, 501)
|
||||
|
||||
def test_head_keep_alive(self):
|
||||
self.con._http_vsn_str = 'HTTP/1.1'
|
||||
|
@ -168,28 +168,28 @@ class BaseHTTPServerTestCase(BaseTestCase):
|
|||
self.con.putheader('Connection', 'keep-alive')
|
||||
self.con.endheaders()
|
||||
res = self.con.getresponse()
|
||||
self.assertEquals(res.status, 501)
|
||||
self.assertEqual(res.status, 501)
|
||||
|
||||
def test_handler(self):
|
||||
self.con.request('TEST', '/')
|
||||
res = self.con.getresponse()
|
||||
self.assertEquals(res.status, 204)
|
||||
self.assertEqual(res.status, 204)
|
||||
|
||||
def test_return_header_keep_alive(self):
|
||||
self.con.request('KEEP', '/')
|
||||
res = self.con.getresponse()
|
||||
self.assertEquals(res.getheader('Connection'), 'keep-alive')
|
||||
self.assertEqual(res.getheader('Connection'), 'keep-alive')
|
||||
self.con.request('TEST', '/')
|
||||
|
||||
def test_internal_key_error(self):
|
||||
self.con.request('KEYERROR', '/')
|
||||
res = self.con.getresponse()
|
||||
self.assertEquals(res.status, 999)
|
||||
self.assertEqual(res.status, 999)
|
||||
|
||||
def test_return_custom_status(self):
|
||||
self.con.request('CUSTOM', '/')
|
||||
res = self.con.getresponse()
|
||||
self.assertEquals(res.status, 999)
|
||||
self.assertEqual(res.status, 999)
|
||||
|
||||
|
||||
class SimpleHTTPServerTestCase(BaseTestCase):
|
||||
|
@ -221,8 +221,8 @@ class SimpleHTTPServerTestCase(BaseTestCase):
|
|||
def check_status_and_reason(self, response, status, data=None):
|
||||
body = response.read()
|
||||
self.assertTrue(response)
|
||||
self.assertEquals(response.status, status)
|
||||
self.assertTrue(response.reason != None)
|
||||
self.assertEqual(response.status, status)
|
||||
self.assertIsNotNone(response.reason)
|
||||
if data:
|
||||
self.assertEqual(data, body)
|
||||
|
||||
|
@ -283,8 +283,8 @@ print "Content-type: text/html"
|
|||
print
|
||||
|
||||
form = cgi.FieldStorage()
|
||||
print "%%s, %%s, %%s" %% (form.getfirst("spam"), form.getfirst("eggs"),\
|
||||
form.getfirst("bacon"))
|
||||
print "%%s, %%s, %%s" %% (form.getfirst("spam"), form.getfirst("eggs"),
|
||||
form.getfirst("bacon"))
|
||||
"""
|
||||
|
||||
class CGIHTTPServerTestCase(BaseTestCase):
|
||||
|
@ -355,38 +355,38 @@ class CGIHTTPServerTestCase(BaseTestCase):
|
|||
CGIHTTPServer._url_collapse_path_split, path)
|
||||
else:
|
||||
actual = CGIHTTPServer._url_collapse_path_split(path)
|
||||
self.assertEquals(expected, actual,
|
||||
msg='path = %r\nGot: %r\nWanted: %r' % (
|
||||
path, actual, expected))
|
||||
self.assertEqual(expected, actual,
|
||||
msg='path = %r\nGot: %r\nWanted: %r' %
|
||||
(path, actual, expected))
|
||||
|
||||
def test_headers_and_content(self):
|
||||
res = self.request('/cgi-bin/file1.py')
|
||||
self.assertEquals(('Hello World\n', 'text/html', 200), \
|
||||
(res.read(), res.getheader('Content-type'), res.status))
|
||||
self.assertEqual(('Hello World\n', 'text/html', 200),
|
||||
(res.read(), res.getheader('Content-type'), res.status))
|
||||
|
||||
def test_post(self):
|
||||
params = urllib.urlencode({'spam' : 1, 'eggs' : 'python', 'bacon' : 123456})
|
||||
headers = {'Content-type' : 'application/x-www-form-urlencoded'}
|
||||
res = self.request('/cgi-bin/file2.py', 'POST', params, headers)
|
||||
|
||||
self.assertEquals(res.read(), '1, python, 123456\n')
|
||||
self.assertEqual(res.read(), '1, python, 123456\n')
|
||||
|
||||
def test_invaliduri(self):
|
||||
res = self.request('/cgi-bin/invalid')
|
||||
res.read()
|
||||
self.assertEquals(res.status, 404)
|
||||
self.assertEqual(res.status, 404)
|
||||
|
||||
def test_authorization(self):
|
||||
headers = {'Authorization' : 'Basic %s' % \
|
||||
base64.b64encode('username:pass')}
|
||||
headers = {'Authorization' : 'Basic %s' %
|
||||
base64.b64encode('username:pass')}
|
||||
res = self.request('/cgi-bin/file1.py', 'GET', headers=headers)
|
||||
self.assertEquals(('Hello World\n', 'text/html', 200), \
|
||||
(res.read(), res.getheader('Content-type'), res.status))
|
||||
self.assertEqual(('Hello World\n', 'text/html', 200),
|
||||
(res.read(), res.getheader('Content-type'), res.status))
|
||||
|
||||
def test_no_leading_slash(self):
|
||||
# http://bugs.python.org/issue2254
|
||||
res = self.request('cgi-bin/file1.py')
|
||||
self.assertEquals(('Hello World\n', 'text/html', 200),
|
||||
self.assertEqual(('Hello World\n', 'text/html', 200),
|
||||
(res.read(), res.getheader('Content-type'), res.status))
|
||||
|
||||
|
||||
|
|
|
@ -247,7 +247,7 @@ class ImportHooksTestCase(ImportHooksBaseTestCase):
|
|||
for n in sys.modules.keys():
|
||||
if n.startswith(parent):
|
||||
del sys.modules[n]
|
||||
with test_support.check_py3k_warnings(), test_support.check_warnings():
|
||||
with test_support.check_warnings():
|
||||
for mname in mnames:
|
||||
m = __import__(mname, globals(), locals(), ["__dummy__"])
|
||||
m.__loader__ # to make sure we actually handled the import
|
||||
|
|
|
@ -170,7 +170,7 @@ class ListTestCase(SeqTestCase):
|
|||
|
||||
lst = [5, 6, 7, 8, 9, 11]
|
||||
l2 = lst.__imul__(self.n)
|
||||
self.assertTrue(l2 is lst)
|
||||
self.assertIs(l2, lst)
|
||||
self.assertEqual(lst, [5, 6, 7, 8, 9, 11] * 3)
|
||||
|
||||
|
||||
|
@ -214,6 +214,9 @@ class TupleTestCase(SeqTestCase):
|
|||
class StringTestCase(SeqTestCase):
|
||||
seq = "this is a test"
|
||||
|
||||
class ByteArrayTestCase(SeqTestCase):
|
||||
seq = bytearray("this is a test")
|
||||
|
||||
class UnicodeTestCase(SeqTestCase):
|
||||
seq = u"this is a test"
|
||||
|
||||
|
@ -265,7 +268,7 @@ class OverflowTestCase(unittest.TestCase):
|
|||
def _getslice_helper_deprecated(self, base):
|
||||
class GetItem(base):
|
||||
def __len__(self):
|
||||
return maxint #cannot return long here
|
||||
return maxint # cannot return long here
|
||||
def __getitem__(self, key):
|
||||
return key
|
||||
def __getslice__(self, i, j):
|
||||
|
@ -299,6 +302,7 @@ def test_main():
|
|||
BaseTestCase,
|
||||
ListTestCase,
|
||||
TupleTestCase,
|
||||
ByteArrayTestCase,
|
||||
StringTestCase,
|
||||
UnicodeTestCase,
|
||||
ClassicSeqTestCase,
|
||||
|
|
|
@ -950,7 +950,7 @@ class MinidomTest(unittest.TestCase):
|
|||
node = doc.documentElement
|
||||
node.childNodes[1].nodeValue = ""
|
||||
node.normalize()
|
||||
self.confirm(node.childNodes[-1].nextSibling == None,
|
||||
self.confirm(node.childNodes[-1].nextSibling is None,
|
||||
"Final child's .nextSibling should be None")
|
||||
|
||||
def testSiblings(self):
|
||||
|
|
|
@ -12,7 +12,7 @@ class TestGetProfile(unittest.TestCase):
|
|||
sys.setprofile(None)
|
||||
|
||||
def test_empty(self):
|
||||
assert sys.getprofile() == None
|
||||
assert sys.getprofile() is None
|
||||
|
||||
def test_setget(self):
|
||||
def fn(*args):
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
import unittest
|
||||
from test.test_support import check_syntax_error, run_unittest
|
||||
from test.test_support import check_syntax_error, check_py3k_warnings, \
|
||||
check_warnings, run_unittest
|
||||
|
||||
import warnings
|
||||
warnings.filterwarnings("ignore", r"import \*", SyntaxWarning, "<test string>")
|
||||
warnings.filterwarnings("ignore", r"import \*", SyntaxWarning, "<string>")
|
||||
|
||||
class ScopeTests(unittest.TestCase):
|
||||
|
||||
|
@ -321,11 +319,14 @@ else:
|
|||
|
||||
self.assertEqual(makeReturner2(a=11)()['a'], 11)
|
||||
|
||||
def makeAddPair((a, b)):
|
||||
def addPair((c, d)):
|
||||
return (a + c, b + d)
|
||||
return addPair
|
||||
|
||||
with check_py3k_warnings(("tuple parameter unpacking has been removed",
|
||||
SyntaxWarning)):
|
||||
exec """\
|
||||
def makeAddPair((a, b)):
|
||||
def addPair((c, d)):
|
||||
return (a + c, b + d)
|
||||
return addPair
|
||||
""" in locals()
|
||||
self.assertEqual(makeAddPair((1, 2))((100, 200)), (101,202))
|
||||
|
||||
def testScopeOfGlobalStmt(self):
|
||||
|
@ -471,7 +472,7 @@ self.assertTrue(X.passed)
|
|||
return g
|
||||
|
||||
d = f(2)(4)
|
||||
self.assertTrue(d.has_key('h'))
|
||||
self.assertIn('h', d)
|
||||
del d['h']
|
||||
self.assertEqual(d, {'x': 2, 'y': 7, 'w': 6})
|
||||
|
||||
|
@ -648,7 +649,9 @@ result2 = h()
|
|||
|
||||
|
||||
def test_main():
|
||||
run_unittest(ScopeTests)
|
||||
with check_warnings(("import \* only allowed at module level",
|
||||
SyntaxWarning)):
|
||||
run_unittest(ScopeTests)
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_main()
|
||||
|
|
|
@ -236,6 +236,7 @@ class ProxyAuthTests(BaseTestCase):
|
|||
REALM = "TestRealm"
|
||||
|
||||
def setUp(self):
|
||||
super(ProxyAuthTests, self).setUp()
|
||||
self.digest_auth_handler = DigestAuthHandler()
|
||||
self.digest_auth_handler.set_users({self.USER: self.PASSWD})
|
||||
self.digest_auth_handler.set_realm(self.REALM)
|
||||
|
@ -252,6 +253,7 @@ class ProxyAuthTests(BaseTestCase):
|
|||
|
||||
def tearDown(self):
|
||||
self.server.stop()
|
||||
super(ProxyAuthTests, self).tearDown()
|
||||
|
||||
def test_proxy_with_bad_password_raises_httperror(self):
|
||||
self.proxy_digest_handler.add_password(self.REALM, self.URL,
|
||||
|
|
Loading…
Reference in New Issue