[Python-checkins] CVS: python/dist/src/Lib Cookie.py,1.7,1.8

Guido van Rossum gvanrossum@users.sourceforge.net
2001年4月06日 12:39:13 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv21451
Modified Files:
	Cookie.py 
Log Message:
Since this module already uses doctest-style examples, I figured I'd
add a self-test using doctest. Results:
- The docstring needs to be a raw string because it uses \"...\".
- The oreo example was broken: the Set-Cookie output doesn't add
 quotes around "doublestuff".
- I had to change the example that prints the class of a Cookie.Cookie
 instance to avoid incorporating an arbitrary object address in the
 test output.
Pretty good score for both doctest and the doc string, I'd say!
Index: Cookie.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/Cookie.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** Cookie.py	2001年02月20日 22:11:24	1.7
--- Cookie.py	2001年04月06日 19:39:11	1.8
***************
*** 40,44 ****
 ####
 
! """
 Here's a sample session to show how to use this module.
 At the moment, this is the only documentation.
--- 40,44 ----
 ####
 
! r"""
 Here's a sample session to show how to use this module.
 At the moment, this is the only documentation.
***************
*** 114,118 ****
 >>> C["oreo"]["path"] = "/"
 >>> print C
! Set-Cookie: oreo="doublestuff"; Path=/;
 
 Each dictionary element has a 'value' attribute, which gives you
--- 114,118 ----
 >>> C["oreo"]["path"] = "/"
 >>> print C
! Set-Cookie: oreo=doublestuff; Path=/;
 
 Each dictionary element has a 'value' attribute, which gives you
***************
*** 204,209 ****
 
 >>> C = Cookie.Cookie()
! >>> C.__class__
! <class Cookie.SmartCookie at 99f88>
 
 
--- 204,209 ----
 
 >>> C = Cookie.Cookie()
! >>> print C.__class__.__name__
! SmartCookie
 
 
***************
*** 722,725 ****
--- 722,731 ----
 ###########################################################
 
+ def _test():
+ import doctest, Cookie
+ return doctest.testmod(Cookie)
+ 
+ if __name__ == "__main__":
+ _test()
 
 

AltStyle によって変換されたページ (->オリジナル) /