@@ -37,7 +37,7 @@ class RealSubject(Subject):
37
37
"""
38
38
39
39
def do_the_job (self , user ):
40
- print (f'> I am doing the job for { user } ' )
40
+ print (f'I am doing the job for { user } ' )
41
41
42
42
43
43
class Proxy (Subject ):
@@ -60,29 +60,28 @@ def do_the_job(self, user):
60
60
def client (job_doer , user ):
61
61
job_doer .do_the_job (user )
62
62
63
- if __name__ == '__main__' :
64
- proxy = Proxy ()
65
- real_subject = RealSubject ()
63
+ def main () :
64
+ """
65
+ >>> proxy = Proxy ()
66
66
67
- print ('# doing the job with proxy:' )
68
- client (proxy , 'admin' )
69
- client (proxy , 'anonymous' )
67
+ >>> real_subject = RealSubject()
70
68
71
- print ()
69
+ >>> client(proxy, 'admin')
70
+ [log] Doing the job for admin is requested.
71
+ I am doing the job for admin
72
72
73
- print ( '# doing the job with real-subject: ' )
74
- client ( real_subject , 'admin' )
75
- client ( real_subject , 'anonymous' )
73
+ >>> client(proxy, 'anonymous ')
74
+ [log] Doing the job for anonymous is requested.
75
+ [log] I can do the job just for `admins`.
76
76
77
+ >>> client(real_subject, 'admin')
78
+ I am doing the job for admin
77
79
78
- OUTPUT = """
79
- # doing the job with proxy:
80
- [log] Doing the job for admin is requested.
81
- > I am doing the job for admin
82
- [log] Doing the job for anonymous is requested.
83
- [log] I can do the job just for `admins`.
80
+ >>> client(real_subject, 'anonymous')
81
+ I am doing the job for anonymous
82
+ """
84
83
85
- # doing the job with real-subject:
86
- > I am doing the job for admin
87
- > I am doing the job for anonymous
88
- """ # noqa
84
+
85
+ if __name__ == '__main__' :
86
+ import doctest
87
+ doctest . testmod ()
0 commit comments