summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_builtin.py9
-rw-r--r--Lib/test/test_cfgparser.py8
-rw-r--r--Lib/test/test_itertools.py3
-rw-r--r--Lib/test/test_parser.py18
-rw-r--r--Lib/test/test_smtplib.py5
5 files changed, 41 insertions, 2 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
index 42c55cc..111090c 100644
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -1829,6 +1829,15 @@ class BuiltinTest(unittest.TestCase):
return i
self.assertRaises(ValueError, list, zip(BadSeq(), BadSeq()))
+ def test_bin(self):
+ self.assertEqual(bin(0), '0b0')
+ self.assertEqual(bin(1), '0b1')
+ self.assertEqual(bin(-1), '-0b1')
+ self.assertEqual(bin(2**65), '0b1' + '0' * 65)
+ self.assertEqual(bin(2**65-1), '0b' + '1' * 65)
+ self.assertEqual(bin(-(2**65)), '-0b1' + '0' * 65)
+ self.assertEqual(bin(-(2**65-1)), '-0b' + '1' * 65)
+
class TestSorted(unittest.TestCase):
def test_basic(self):
diff --git a/Lib/test/test_cfgparser.py b/Lib/test/test_cfgparser.py
index 3ef82be..a2da556 100644
--- a/Lib/test/test_cfgparser.py
+++ b/Lib/test/test_cfgparser.py
@@ -436,6 +436,14 @@ class SafeConfigParserTestCase(ConfigParserTestCase):
self.assertRaises(TypeError, cf.set, "sect", "option2", 1.0)
self.assertRaises(TypeError, cf.set, "sect", "option2", object())
+ def test_add_section_default_1(self):
+ cf = self.newconfig()
+ self.assertRaises(ValueError, cf.add_section, "default")
+
+ def test_add_section_default_2(self):
+ cf = self.newconfig()
+ self.assertRaises(ValueError, cf.add_section, "DEFAULT")
+
class SortedTestCase(RawConfigParserTestCase):
def newconfig(self, defaults=None):
self.cf = self.config_class(defaults=defaults, dict_type=SortedDict)
diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py
index 380d121..744b344 100644
--- a/Lib/test/test_itertools.py
+++ b/Lib/test/test_itertools.py
@@ -283,6 +283,9 @@ class TestBasicOps(unittest.TestCase):
args = map(iter, args)
self.assertEqual(len(list(product(*args))), n)
+ # Test implementation detail: tuple re-use
+ self.assertEqual(len(set(map(id, product('abc', 'def')))), 1)
+ self.assertNotEqual(len(set(map(id, list(product('abc', 'def'))))), 1)
def test_repeat(self):
self.assertEqual(lzip(range(3),repeat('a')),
diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py
index 3bebe7e..054d6d2 100644
--- a/Lib/test/test_parser.py
+++ b/Lib/test/test_parser.py
@@ -450,11 +450,29 @@ class CompileTestCase(unittest.TestCase):
st = parser.suite('a = "\\u1"')
self.assertRaises(SyntaxError, parser.compilest, st)
+class ParserStackLimitTestCase(unittest.TestCase):
+ """try to push the parser to/over it's limits.
+ see http://bugs.python.org/issue1881 for a discussion
+ """
+ def _nested_expression(self, level):
+ return "["*level+"]"*level
+
+ def test_deeply_nested_list(self):
+ # XXX used to be 99 levels in 2.x
+ e = self._nested_expression(93)
+ st = parser.expr(e)
+ st.compile()
+
+ def test_trigger_memory_error(self):
+ e = self._nested_expression(100)
+ self.assertRaises(MemoryError, parser.expr, e)
+
def test_main():
test_support.run_unittest(
RoundtripLegalSyntaxTestCase,
IllegalSyntaxTestCase,
CompileTestCase,
+ ParserStackLimitTestCase,
)
diff --git a/Lib/test/test_smtplib.py b/Lib/test/test_smtplib.py
index 4151d6b..6b00b80 100644
--- a/Lib/test/test_smtplib.py
+++ b/Lib/test/test_smtplib.py
@@ -82,8 +82,9 @@ class GeneralTests(TestCase):
# to reference the nonexistent 'sock' attribute of the SMTP object
# causes an AttributeError)
smtp = smtplib.SMTP()
- self.assertRaises(AttributeError, smtp.ehlo)
- self.assertRaises(AttributeError, smtp.send, 'test msg')
+ self.assertRaises(smtplib.SMTPServerDisconnected, smtp.ehlo)
+ self.assertRaises(smtplib.SMTPServerDisconnected,
+ smtp.send, 'test msg')
def testLocalHostName(self):
# check that supplied local_hostname is used