Discussion:
[Python-3000-checkins] r66563 - python/branches/py3k/Lib/test/test_atexit.py
benjamin.peterson
2008-09-23 03:14:49 UTC
Permalink
Author: benjamin.peterson
Date: Tue Sep 23 05:14:49 2008
New Revision: 66563

Log:
add a test for bad atexit arguments

Modified:
python/branches/py3k/Lib/test/test_atexit.py

Modified: python/branches/py3k/Lib/test/test_atexit.py
==============================================================================
--- python/branches/py3k/Lib/test/test_atexit.py (original)
+++ python/branches/py3k/Lib/test/test_atexit.py Tue Sep 23 05:14:49 2008
@@ -44,6 +44,10 @@
self.assertEqual(self.stream.getvalue(),
"h4 (4,) {'kw': 'abc'}\nh4 () {}\nh1\n")

+ def test_badargs(self):
+ atexit.register(lambda: 1, 0, 0, (x for x in (1,2)), 0, 0)
+ self.assertRaises(TypeError, atexit._run_exitfuncs)
+
def test_order(self):
# be sure handlers are executed in reverse order
atexit.register(h1)
Skip Montanaro
2008-09-23 03:26:35 UTC
Permalink
backport?

def test_badargs(self):
s = StringIO.StringIO()
sys.stdout = sys.stderr = s
save_handlers = atexit._exithandlers
atexit._exithandlers = []
try:
atexit.register(lambda: 1, 0, 0, (x for x in (1,2)), 0, 0)
self.assertRaises(TypeError, atexit._run_exitfuncs)
finally:
sys.stdout = sys.__stdout__
sys.stderr = sys.__stderr__
atexit._exithandlers = save_handlers

S
Benjamin Peterson
2008-09-23 20:31:17 UTC
Permalink
On Mon, Sep 22, 2008 at 10:26 PM, Skip Montanaro
Post by Skip Montanaro
backport?
Will do.
Post by Skip Montanaro
s = StringIO.StringIO()
sys.stdout = sys.stderr = s
save_handlers = atexit._exithandlers
atexit._exithandlers = []
atexit.register(lambda: 1, 0, 0, (x for x in (1,2)), 0, 0)
self.assertRaises(TypeError, atexit._run_exitfuncs)
sys.stdout = sys.__stdout__
sys.stderr = sys.__stderr__
atexit._exithandlers = save_handlers
This is already done in the setUp and tearDown methods.
--
Cheers,
Benjamin Peterson
"There's no place like 127.0.0.1."
Loading...