@@ -37,7 +37,7 @@ class RealSubject(Subject):
3737 """
3838
3939 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 } ' )
4141
4242
4343class Proxy (Subject ):
@@ -60,29 +60,28 @@ def do_the_job(self, user):
6060def client (job_doer , user ):
6161 job_doer .do_the_job (user )
6262
63- if __name__ == '__main__' :
64- proxy = Proxy ()
65- real_subject = RealSubject ()
63+ def main () :
64+ """
65+ >>> proxy = Proxy ()
6666
67- print ('# doing the job with proxy:' )
68- client (proxy , 'admin' )
69- client (proxy , 'anonymous' )
67+ >>> real_subject = RealSubject()
7068
71- print ()
69+ >>> client(proxy, 'admin')
70+ [log] Doing the job for admin is requested.
71+ I am doing the job for admin
7272
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`.
7676
77+ >>> client(real_subject, 'admin')
78+ I am doing the job for admin
7779
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+ """
8483
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