Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
test.test_atexit.TestCase Class Reference

List of all members.

Public Member Functions

def setUp
def tearDown
def test_args
def test_badargs
def test_order
def test_raise
def test_raise_unnormalized
def test_stress
def test_clear
def test_unregister
def test_bound_methods

Public Attributes

 save_stdout
 save_stderr
 stream

Detailed Description

Definition at line 26 of file test_atexit.py.


Member Function Documentation

Definition at line 27 of file test_atexit.py.

00027 
00028     def setUp(self):
00029         self.save_stdout = sys.stdout
00030         self.save_stderr = sys.stderr
00031         self.stream = io.StringIO()
00032         sys.stdout = sys.stderr = self.stream
00033         atexit._clear()

Here is the caller graph for this function:

Definition at line 34 of file test_atexit.py.

00034 
00035     def tearDown(self):
00036         sys.stdout = self.save_stdout
00037         sys.stderr = self.save_stderr
00038         atexit._clear()

Here is the caller graph for this function:

Definition at line 39 of file test_atexit.py.

00039 
00040     def test_args(self):
00041         # be sure args are handled properly
00042         atexit.register(h1)
00043         atexit.register(h4)
00044         atexit.register(h4, 4, kw="abc")
00045         atexit._run_exitfuncs()
00046 
00047         self.assertEqual(self.stream.getvalue(),
00048                             "h4 (4,) {'kw': 'abc'}\nh4 () {}\nh1\n")

Here is the call graph for this function:

Definition at line 49 of file test_atexit.py.

00049 
00050     def test_badargs(self):
00051         atexit.register(lambda: 1, 0, 0, (x for x in (1,2)), 0, 0)
00052         self.assertRaises(TypeError, atexit._run_exitfuncs)

Here is the call graph for this function:

Definition at line 114 of file test_atexit.py.

00114 
00115     def test_bound_methods(self):
00116         l = []
00117         atexit.register(l.append, 5)
00118         atexit._run_exitfuncs()
00119         self.assertEqual(l, [5])
00120 
00121         atexit.unregister(l.append)
00122         atexit._run_exitfuncs()
00123         self.assertEqual(l, [5])
00124 

Here is the call graph for this function:

Definition at line 88 of file test_atexit.py.

00088 
00089     def test_clear(self):
00090         a = [0]
00091         def inc():
00092             a[0] += 1
00093 
00094         atexit.register(inc)
00095         atexit._clear()
00096         atexit._run_exitfuncs()
00097 
00098         self.assertEqual(a[0], 0)

Here is the call graph for this function:

Definition at line 53 of file test_atexit.py.

00053 
00054     def test_order(self):
00055         # be sure handlers are executed in reverse order
00056         atexit.register(h1)
00057         atexit.register(h2)
00058         atexit.register(h3)
00059         atexit._run_exitfuncs()
00060 
00061         self.assertEqual(self.stream.getvalue(), "h3\nh2\nh1\n")

Here is the call graph for this function:

Definition at line 62 of file test_atexit.py.

00062 
00063     def test_raise(self):
00064         # be sure raises are handled properly
00065         atexit.register(raise1)
00066         atexit.register(raise2)
00067 
00068         self.assertRaises(TypeError, atexit._run_exitfuncs)

Here is the call graph for this function:

Definition at line 69 of file test_atexit.py.

00069 
00070     def test_raise_unnormalized(self):
00071         # Issue #10756: Make sure that an unnormalized exception is
00072         # handled properly
00073         atexit.register(lambda: 1 / 0)
00074 
00075         self.assertRaises(ZeroDivisionError, atexit._run_exitfuncs)
00076         self.assertIn("ZeroDivisionError", self.stream.getvalue())

Here is the call graph for this function:

Definition at line 77 of file test_atexit.py.

00077 
00078     def test_stress(self):
00079         a = [0]
00080         def inc():
00081             a[0] += 1
00082 
00083         for i in range(128):
00084             atexit.register(inc)
00085         atexit._run_exitfuncs()
00086 
00087         self.assertEqual(a[0], 128)

Here is the call graph for this function:

Definition at line 99 of file test_atexit.py.

00099 
00100     def test_unregister(self):
00101         a = [0]
00102         def inc():
00103             a[0] += 1
00104         def dec():
00105             a[0] -= 1
00106 
00107         for i in range(4):
00108             atexit.register(inc)
00109         atexit.register(dec)
00110         atexit.unregister(inc)
00111         atexit._run_exitfuncs()
00112 
00113         self.assertEqual(a[0], -1)

Here is the call graph for this function:


Member Data Documentation

Definition at line 29 of file test_atexit.py.

Definition at line 28 of file test_atexit.py.

Definition at line 30 of file test_atexit.py.


The documentation for this class was generated from the following file: