Commit e5806058 authored by Jim Fulton's avatar Jim Fulton

more work on first cut

parent 0318a786
Attr.py
Basic.py
Exceptions.py
Mapping.py
Method.py
Number.py
Standard.py
Util.py
__init__.py
iclass.py
R=$1
M=Interface
for f in test.py `cat pyfiles`; do
python1.5.1 /projects/sbin/tabnanny.py $f
done
mkdir "$M-$R" "$M-$R/Interface"
for f in `cat pyfiles`; do
cp $f "$M-$R/Interface/"
done
for f in README.txt test.py; do
cp $f "$M-$R/"
done
tar cvf "$M-$R.tar" "$M-$R"
rm -f "$M-$R.tar.gz"
gzip "$M-$R.tar"
import Interface
class C:
def m1(self, a, b):
"return 1"
return 1
def m2(self, a, b):
"return 2"
return 2
IC=Interface.impliedInterface(C)
print "should be 0:", IC.implementedByInstancesOf(C)
C.__implements__=IC
print "should be 1:", IC.implementedByInstancesOf(C)
class I1(Interface.Base):
def ma(self):
"blah"
class I2(I1): pass
class I3(Interface.Base): pass
class I4(Interface.Base): pass
class A(I1.defered()):
__implements__=I1
class B:
__implements__=I2, I3
class D(A, B): pass
class E(A, B):
__implements__ = A.__implements__, C.__implements__
print
for c in A, B, C, D, E:
print "%s implements: %s" % (
c.__name__, Interface.implementedByInstancesOf(c))
print
for c in A, B, C, D, E:
print "an instance of %s implements: %s" % (
c.__name__,
Interface.implementedBy(c()))
for i in I1, I2, I3, I4, IC:
print
for c in A, B, C, D, E:
print "%s is implemented by instances of %s? %s" % (
i.__name__, c.__name__,
i.implementedByInstancesOf(c))
print
for c in A, B, C, D, E:
print "%s is implemented by an instance of %s? %s" % (
i.__name__, c.__name__,
i.implementedBy(c()))
a=A()
try:
a.ma()
print "something's wrong, this should have failed!"
except:
pass
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment