Back to index

python3.2  3.2.2
Public Member Functions
ctypes.test.test_random_things.CallbackTracbackTestCase Class Reference

List of all members.

Public Member Functions

def capture_stderr
def test_ValueError
def test_IntegerDivisionError
def test_FloatDivisionError
def test_TypeErrorDivisionError

Detailed Description

Definition at line 26 of file test_random_things.py.


Member Function Documentation

Definition at line 38 of file test_random_things.py.

00038 
00039     def capture_stderr(self, func, *args, **kw):
00040         # helper - call function 'func', and return the captured stderr
00041         import io
00042         old_stderr = sys.stderr
00043         logger = sys.stderr = io.StringIO()
00044         try:
00045             func(*args, **kw)
00046         finally:
00047             sys.stderr = old_stderr
00048         return logger.getvalue()

Here is the caller graph for this function:

Definition at line 61 of file test_random_things.py.

00061 
00062     def test_FloatDivisionError(self):
00063         cb = CFUNCTYPE(c_int, c_double)(callback_func)
00064         out = self.capture_stderr(cb, 0.0)
00065         self.assertEqual(out.splitlines()[-1][:19],
00066                              "ZeroDivisionError: ")

Here is the call graph for this function:

Definition at line 55 of file test_random_things.py.

00055 
00056     def test_IntegerDivisionError(self):
00057         cb = CFUNCTYPE(c_int, c_int)(callback_func)
00058         out = self.capture_stderr(cb, 0)
00059         self.assertEqual(out.splitlines()[-1][:19],
00060                              "ZeroDivisionError: ")

Here is the call graph for this function:

Definition at line 67 of file test_random_things.py.

00067 
00068     def test_TypeErrorDivisionError(self):
00069         cb = CFUNCTYPE(c_int, c_char_p)(callback_func)
00070         out = self.capture_stderr(cb, b"spam")
00071         self.assertEqual(out.splitlines()[-1],
00072                              "TypeError: "
00073                              "unsupported operand type(s) for /: 'int' and 'bytes'")

Here is the call graph for this function:

Definition at line 49 of file test_random_things.py.

00049 
00050     def test_ValueError(self):
00051         cb = CFUNCTYPE(c_int, c_int)(callback_func)
00052         out = self.capture_stderr(cb, 42)
00053         self.assertEqual(out.splitlines()[-1],
00054                              "ValueError: 42")

Here is the call graph for this function:


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