Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions
test.test_urllib2.MockHandler Class Reference

List of all members.

Public Member Functions

def __init__
def handle
def close
def add_parent
def __lt__

Public Attributes

 parent

Static Public Attributes

int handler_order = 500

Private Member Functions

def _define_methods

Detailed Description

Definition at line 323 of file test_urllib2.py.


Constructor & Destructor Documentation

def test.test_urllib2.MockHandler.__init__ (   self,
  methods 
)

Definition at line 327 of file test_urllib2.py.

00327 
00328     def __init__(self, methods):
        self._define_methods(methods)

Here is the call graph for this function:

Here is the caller graph for this function:


Member Function Documentation

def test.test_urllib2.MockHandler.__lt__ (   self,
  other 
)

Definition at line 361 of file test_urllib2.py.

00361 
00362     def __lt__(self, other):
00363         if not hasattr(other, "handler_order"):
00364             # No handler_order, leave in original order.  Yuck.
00365             return True
00366         return self.handler_order < other.handler_order

def test.test_urllib2.MockHandler._define_methods (   self,
  methods 
) [private]

Definition at line 329 of file test_urllib2.py.

00329 
00330     def _define_methods(self, methods):
00331         for spec in methods:
00332             if len(spec) == 2: name, action = spec
00333             else: name, action = spec, None
00334             meth = FakeMethod(name, action, self.handle)
            setattr(self.__class__, name, meth)

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_urllib2.MockHandler.add_parent (   self,
  parent 
)

Definition at line 358 of file test_urllib2.py.

00358 
00359     def add_parent(self, parent):
00360         self.parent = parent
        self.parent.calls = []

Definition at line 357 of file test_urllib2.py.

00357 
    def close(self): pass

Here is the caller graph for this function:

def test.test_urllib2.MockHandler.handle (   self,
  fn_name,
  action,
  args,
  kwds 
)

Definition at line 335 of file test_urllib2.py.

00335 
00336     def handle(self, fn_name, action, *args, **kwds):
00337         self.parent.calls.append((self, fn_name, args, kwds))
00338         if action is None:
00339             return None
00340         elif action == "return self":
00341             return self
00342         elif action == "return response":
00343             res = MockResponse(200, "OK", {}, "")
00344             return res
00345         elif action == "return request":
00346             return Request("http://blah/")
00347         elif action.startswith("error"):
00348             code = action[action.rfind(" ")+1:]
00349             try:
00350                 code = int(code)
00351             except ValueError:
00352                 pass
00353             res = MockResponse(200, "OK", {}, "")
00354             return self.parent.error("http", args[0], res, code, "", {})
00355         elif action == "raise":
00356             raise urllib.error.URLError("blah")
        assert False

Here is the caller graph for this function:


Member Data Documentation

Definition at line 326 of file test_urllib2.py.

Definition at line 359 of file test_urllib2.py.


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