#NEWLINE# def test_implements_only( self ) : #NEWLINE# #INDENT# class ICreature ( Interface ) : #NEWLINE# #INDENT# age = 'Age in years.' #NEWLINE# #UNINDENT# class IPerson ( ICreature ) : #NEWLINE# #INDENT# first_name = Attribute ( 'First name.' ) #NEWLINE# last_name = Attribute ( 'Last name.' ) #NEWLINE# def get_full_name( ) : #NEWLINE# #INDENT# "Returns person's full name." #NEWLINE# #UNINDENT# #UNINDENT# class IObject ( Interface ) : #NEWLINE# #INDENT# id = 'Database ID.' #NEWLINE# #UNINDENT# class IDuck ( Interface ) : #NEWLINE# #INDENT# def quack( ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# @ implements ( IPerson , IObject ) #NEWLINE# class Person ( object ) : #NEWLINE# #INDENT# 'Person class.' #NEWLINE# def __init__( self ) : #NEWLINE# #INDENT# self . id = 1 #NEWLINE# self . first_name = 'Foo' #NEWLINE# self . last_name = 'Bar' #NEWLINE# #UNINDENT# def get_full_name( self ) : #NEWLINE# #INDENT# return '{} {}' . format ( self . first_name , self . last_name ) #NEWLINE# #UNINDENT# #UNINDENT# @ implements_only ( IDuck ) #NEWLINE# class Duck ( Person ) : #NEWLINE# #INDENT# 'Duck class.' #NEWLINE# def quack( self ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# self . assertSetEqual ( get_implemented_interfaces ( Duck ) , set ( [ IDuck ] ) ) #NEWLINE# self . assertSetEqual ( get_implemented_interfaces ( Person ) , set ( [ ICreature , IPerson , IObject ] ) ) #NEWLINE# self . assertEqual ( Duck . __name__ , 'Duck' ) #NEWLINE# self . assertEqual ( inspect . getdoc ( Duck ) , 'Duck class.' ) #NEWLINE# self . assertIsImplementation ( Duck , [ ] ) #NEWLINE# self . assertIsImplementation ( Duck , IDuck ) #NEWLINE# self . assertIsImplementation ( Duck , [ IDuck ] ) #NEWLINE# self . assertNotIsImplementation ( Duck , IPerson ) #NEWLINE# self . assertNotIsImplementation ( Duck , IObject ) #NEWLINE# self . assertNotIsImplementation ( Duck , [ IPerson , IDuck ] ) #NEWLINE# self . assertNotIsImplementation ( Duck , [ IDuck , IObject , IPerson ] ) #NEWLINE# duck = Duck ( ) #NEWLINE# self . assertIsImplementation ( duck , [ ] ) #NEWLINE# self . assertIsImplementation ( duck , IDuck ) #NEWLINE# self . assertIsImplementation ( duck , [ IDuck ] ) #NEWLINE# self . assertNotIsImplementation ( duck , IPerson ) #NEWLINE# self . assertNotIsImplementation ( duck , IObject ) #NEWLINE# self . assertNotIsImplementation ( duck , [ IPerson , IDuck ] ) #NEWLINE# self . assertNotIsImplementation ( self , [ IDuck , IObject , IPerson ] )