/usr/share/pyshared/zope/component/standalonetests.py is in python-zope.component 3.10.0-2.
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 | """
Standalone Tests
"""
import unittest
import doctest
import sys
import pickle
if __name__ == "__main__":
sys.path = pickle.loads(sys.stdin.read())
from zope import interface
from zope.component.testing import setUp, tearDown
class I1(interface.Interface):
pass
class I2(interface.Interface):
pass
class Ob(object):
interface.implements(I1)
def __repr__(self):
return '<instance Ob>'
ob = Ob()
class Comp(object):
interface.implements(I2)
def __init__(self, context):
self.context = context
def providing_adapter_sets_adapter_hook():
"""
A side effect of importing installs the adapter hook. See
http://www.zope.org/Collectors/Zope3-dev/674.
>>> import zope.component
>>> zope.component.provideAdapter(Comp, (I1,), I2)
>>> adapter = I2(ob)
>>> adapter.__class__ is Comp
True
>>> adapter.context is ob
True
"""
def test_suite():
return unittest.TestSuite((
doctest.DocTestSuite(setUp=setUp, tearDown=tearDown),
))
if __name__ == "__main__":
unittest.main(defaultTest='test_suite')
|