Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Private Member Functions
test.test_inspect.TestGetGeneratorState Class Reference

List of all members.

Public Member Functions

def setUp
def test_created
def test_suspended
def test_closed_after_exhaustion
def test_closed_after_immediate_exception
def test_running
def test_easy_debugging

Public Attributes

 generator

Private Member Functions

def _generatorstate

Detailed Description

Definition at line 1007 of file test_inspect.py.


Member Function Documentation

Definition at line 1015 of file test_inspect.py.

01015 
01016     def _generatorstate(self):
01017         return inspect.getgeneratorstate(self.generator)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1009 of file test_inspect.py.

01009 
01010     def setUp(self):
01011         def number_generator():
01012             for number in range(5):
01013                 yield number
01014         self.generator = number_generator()

Here is the caller graph for this function:

Definition at line 1025 of file test_inspect.py.

01025 
01026     def test_closed_after_exhaustion(self):
01027         for i in self.generator:
01028             pass
01029         self.assertEqual(self._generatorstate(), inspect.GEN_CLOSED)

Here is the call graph for this function:

Definition at line 1030 of file test_inspect.py.

01030 
01031     def test_closed_after_immediate_exception(self):
01032         with self.assertRaises(RuntimeError):
01033             self.generator.throw(RuntimeError)
01034         self.assertEqual(self._generatorstate(), inspect.GEN_CLOSED)

Here is the call graph for this function:

Definition at line 1018 of file test_inspect.py.

01018 
01019     def test_created(self):
01020         self.assertEqual(self._generatorstate(), inspect.GEN_CREATED)

Here is the call graph for this function:

Definition at line 1051 of file test_inspect.py.

01051 
01052     def test_easy_debugging(self):
01053         # repr() and str() of a generator state should contain the state name
01054         names = 'GEN_CREATED GEN_RUNNING GEN_SUSPENDED GEN_CLOSED'.split()
01055         for name in names:
01056             state = getattr(inspect, name)
01057             self.assertIn(name, repr(state))
01058             self.assertIn(name, str(state))
01059 

Here is the call graph for this function:

Definition at line 1035 of file test_inspect.py.

01035 
01036     def test_running(self):
01037         # As mentioned on issue #10220, checking for the RUNNING state only
01038         # makes sense inside the generator itself.
01039         # The following generator checks for this by using the closure's
01040         # reference to self and the generator state checking helper method
01041         def running_check_generator():
01042             for number in range(5):
01043                 self.assertEqual(self._generatorstate(), inspect.GEN_RUNNING)
01044                 yield number
01045                 self.assertEqual(self._generatorstate(), inspect.GEN_RUNNING)
01046         self.generator = running_check_generator()
01047         # Running up to the first yield
01048         next(self.generator)
01049         # Running after the first yield
01050         next(self.generator)

Here is the call graph for this function:

Definition at line 1021 of file test_inspect.py.

01021 
01022     def test_suspended(self):
01023         next(self.generator)
01024         self.assertEqual(self._generatorstate(), inspect.GEN_SUSPENDED)

Here is the call graph for this function:


Member Data Documentation

Definition at line 1013 of file test_inspect.py.


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