~soren/nova/iptables-security-groups

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/twisted/web/test/_util.py

  • Committer: Jesse Andrews
  • Date: 2010-05-28 06:05:26 UTC
  • Revision ID: git-v1:bf6e6e718cdc7488e2da87b21e258ccc065fe499
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (c) 2008 Twisted Matrix Laboratories.
 
2
# See LICENSE for details.
 
3
 
 
4
"""
 
5
General helpers for L{twisted.web} unit tests.
 
6
"""
 
7
 
 
8
from twisted.internet.defer import succeed
 
9
from twisted.web import server
 
10
 
 
11
 
 
12
def _render(resource, request):
 
13
    result = resource.render(request)
 
14
    if isinstance(result, str):
 
15
        request.write(result)
 
16
        request.finish()
 
17
        return succeed(None)
 
18
    elif result is server.NOT_DONE_YET:
 
19
        if request.finished:
 
20
            return succeed(None)
 
21
        else:
 
22
            return request.notifyFinish()
 
23
    else:
 
24
        raise ValueError("Unexpected return value: %r" % (result,))