/
usr
/
lib
/
python3
/
dist-packages
/
twisted
/
web
/
test
/
/usr/lib/python3/dist-packages/twisted/web/test
mkdir
upload
Name
Size
Mode
Actions
__pycache__/
-
0755
rm
injectionhelpers.py
5627
0644
edit
dl
rm
requesthelper.py
13406
0644
edit
dl
rm
test_agent.py
117805
0644
edit
dl
rm
test_cgi.py
13761
0644
edit
dl
rm
test_client.py
1372
0644
edit
dl
rm
test_distrib.py
18288
0644
edit
dl
rm
test_domhelpers.py
11103
0644
edit
dl
rm
test_error.py
16210
0644
edit
dl
rm
test_flatten.py
18259
0644
edit
dl
rm
test_html.py
1264
0644
edit
dl
rm
test_http.py
136566
0644
edit
dl
rm
test_http2.py
109983
0644
edit
dl
rm
test_httpauth.py
24128
0644
edit
dl
rm
test_http_headers.py
20386
0644
edit
dl
rm
test_newclient.py
108751
0644
edit
dl
rm
test_proxy.py
20092
0644
edit
dl
rm
test_resource.py
8214
0644
edit
dl
rm
test_script.py
3784
0644
edit
dl
rm
test_stan.py
5667
0644
edit
dl
rm
test_static.py
67858
0644
edit
dl
rm
test_tap.py
10947
0644
edit
dl
rm
test_template.py
25977
0644
edit
dl
rm
test_util.py
13900
0644
edit
dl
rm
test_vhost.py
7917
0644
edit
dl
rm
test_web.py
65996
0644
edit
dl
rm
test_webclient.py
59615
0644
edit
dl
rm
test_web__responses.py
877
0644
edit
dl
rm
test_wsgi.py
78210
0644
edit
dl
rm
test_xml.py
42357
0644
edit
dl
rm
test_xmlrpc.py
30302
0644
edit
dl
rm
_util.py
2568
0644
edit
dl
rm
__init__.py
108
0644
edit
dl
rm
Edit:
/usr/lib/python3/dist-packages/twisted/web/test/_util.py
(2568B)
# Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ General helpers for L{twisted.web} unit tests. """ from __future__ import division, absolute_import from twisted.internet.defer import succeed from twisted.web import server from twisted.trial.unittest import TestCase from twisted.python.failure import Failure from twisted.web._flatten import flattenString from twisted.web.error import FlattenerError def _render(resource, request): result = resource.render(request) if isinstance(result, bytes): request.write(result) request.finish() return succeed(None) elif result is server.NOT_DONE_YET: if request.finished: return succeed(None) else: return request.notifyFinish() else: raise ValueError("Unexpected return value: %r" % (result,)) class FlattenTestCase(TestCase): """ A test case that assists with testing L{twisted.web._flatten}. """ def assertFlattensTo(self, root, target): """ Assert that a root element, when flattened, is equal to a string. """ d = flattenString(None, root) d.addCallback(lambda s: self.assertEqual(s, target)) return d def assertFlattensImmediately(self, root, target): """ Assert that a root element, when flattened, is equal to a string, and performs no asynchronus Deferred anything. This version is more convenient in tests which wish to make multiple assertions about flattening, since it can be called multiple times without having to add multiple callbacks. @return: the result of rendering L{root}, which should be equivalent to L{target}. @rtype: L{bytes} """ results = [] it = self.assertFlattensTo(root, target) it.addBoth(results.append) # Do our best to clean it up if something goes wrong. self.addCleanup(it.cancel) if not results: self.fail("Rendering did not complete immediately.") result = results[0] if isinstance(result, Failure): result.raiseException() return results[0] def assertFlatteningRaises(self, root, exn): """ Assert flattening a root element raises a particular exception. """ d = self.assertFailure(self.assertFlattensTo(root, b''), FlattenerError) d.addCallback(lambda exc: self.assertIsInstance(exc._exception, exn)) return d __all__ = ["_render", "FlattenTestCase"]
Save
cmd:
run