File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88chaining together using boolean logic
99"""
1010
11- from abc import ABCMeta , abstractmethod
11+ from abc import abstractmethod
1212
1313
14- class Specification :
15- __metaclass__ = ABCMeta
14+ class Specification (object ):
1615
1716 def and_specification (self , candidate ):
18- raise NotImplementedError
17+ raise NotImplementedError ()
1918
2019 def or_specification (self , candidate ):
21- raise NotImplementedError
20+ raise NotImplementedError ()
2221
2322 def not_specification (self ):
24- raise NotImplementedError
23+ raise NotImplementedError ()
2524
2625 @abstractmethod
2726 def is_satisfied_by (self , candidate ):
@@ -101,10 +100,18 @@ def is_satisfied_by(self, candidate):
101100 print ('Specification' )
102101 andrey = User ()
103102 ivan = User (super_user = True )
103+ vasiliy = 'not User instance'
104104
105105 root_specification = UserSpecification ().\
106106 and_specification (SuperUserSpecification ())
107107
108108 print (root_specification .is_satisfied_by (andrey ))
109109 print (root_specification .is_satisfied_by (ivan ))
110+ print (root_specification .is_satisfied_by (vasiliy ))
110111
112+
113+ ### OUTPUT ###
114+ # Specification
115+ # False
116+ # True
117+ # False
You can’t perform that action at this time.
0 commit comments