/usr/share/pyshared/twisted/web2/test/test_compat.py is in python-twisted-web2 8.1.0-3build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | from twisted.web2.test.test_server import BaseCase
import sys
try:
from twisted.web import resource
class OldWebResource(resource.Resource):
def __init__(self, message, *args, **kwargs):
self.message = message
resource.Resource.__init__(self, *args, **kwargs)
isLeaf = True
def render(self, req):
return self.message
except ImportError:
resource = None
class OldWebCompat(BaseCase):
try:
import twisted.web
except ImportError:
skip = "can't run w/o twisted.web"
def testOldWebResource(self):
ow = OldWebResource('I am an OldWebResource')
self.assertResponse((ow, "http://localhost/"),
(200, {}, 'I am an OldWebResource'))
def testOldWebResourceNotLeaf(self):
ow = OldWebResource('I am not a leaf')
ow.isLeaf = False
self.assertResponse((ow, "http://localhost/"),
(200, {}, 'I am not a leaf'))
def testOldWebResourceWithChildren(self):
ow = OldWebResource('I am an OldWebResource with a child')
ow.isLeaf = False
ow.putChild('child',
OldWebResource('I am a child of an OldWebResource'))
self.assertResponse((ow, "http://localhost/"),
(200, {},
'I am an OldWebResource with a child'))
self.assertResponse((ow, "http://localhost/child"),
(200, {},
'I am a child of an OldWebResource'))
if not resource:
OldWebCompat.skip = "can't run w/o twisted.web"
|