/usr/lib/python2.7/dist-packages/protocols/tests/test_classes.py is in python-protocols 1.0a.svn20070625-7.
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 | """Tests for implementor declarations (i.e. instancesProvides)"""
from unittest import TestCase, makeSuite, TestSuite
from protocols import *
from checks import ImplementationChecks, AdaptiveChecks, makeClassTests
class IA(Interface): pass
class IB(IA): pass
class IPure(Interface):
# We use this for pickle/copy tests because the other protocols
# imply various dynamically created interfaces, and so any object
# registered with them won't be picklable
pass
class BasicChecks(AdaptiveChecks, ImplementationChecks):
"""PyProtocols-only class-instances-provide checks"""
IA = IA
IB = IB
Interface = Interface
IPure = IPure
def checkChangingBases(self):
# Zope and Twisted fail this because they rely on the first-found
# __implements__ attribute and ignore a class' MRO/__bases__
M1, M2 = self.setupBases(self.klass)
m1 = self.make(M1)
m2 = self.make(M2)
declareImplementation(M1, instancesProvide=[self.IA])
declareImplementation(M2, instancesProvide=[self.IB])
self.assertM1ProvidesOnlyAandM2ProvidesB(m1,m2)
self.assertChangingBasesChangesInterface(M1,M2,m1,m2)
TestClasses = makeClassTests(BasicChecks)
def test_suite():
return TestSuite([makeSuite(t,'check') for t in TestClasses])
|