summaryrefslogtreecommitdiffstats
path: root/Lib/Cookie.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-04-06 19:39:11 (GMT)
committerGuido van Rossum <guido@python.org>2001-04-06 19:39:11 (GMT)
commit58b6f5b53e67878fa3d9bbe4f4112cddf1ebb5cc (patch)
tree9cca0b16e770158e67ed0775f641e471a1338c97 /Lib/Cookie.py
parentf95423e2659a08703e37c7fc111d0f60ad3550a4 (diff)
downloadcpython-58b6f5b53e67878fa3d9bbe4f4112cddf1ebb5cc.zip
cpython-58b6f5b53e67878fa3d9bbe4f4112cddf1ebb5cc.tar.gz
cpython-58b6f5b53e67878fa3d9bbe4f4112cddf1ebb5cc.tar.bz2
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!
Diffstat (limited to 'Lib/Cookie.py')
-rw-r--r--Lib/Cookie.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/Lib/Cookie.py b/Lib/Cookie.py
index f4d73e6..b7ee19c 100644
--- a/Lib/Cookie.py
+++ b/Lib/Cookie.py
@@ -39,7 +39,7 @@
#
####
-"""
+r"""
Here's a sample session to show how to use this module.
At the moment, this is the only documentation.
@@ -113,7 +113,7 @@ attribute.
>>> C["oreo"] = "doublestuff"
>>> C["oreo"]["path"] = "/"
>>> print C
- Set-Cookie: oreo="doublestuff"; Path=/;
+ Set-Cookie: oreo=doublestuff; Path=/;
Each dictionary element has a 'value' attribute, which gives you
back the value associated with the key.
@@ -203,8 +203,8 @@ it is still possible to use Cookie.Cookie() to create a Cookie. In
fact, this simply returns a SmartCookie.
>>> C = Cookie.Cookie()
- >>> C.__class__
- <class Cookie.SmartCookie at 99f88>
+ >>> print C.__class__.__name__
+ SmartCookie
Finis.
@@ -721,6 +721,12 @@ Cookie = SmartCookie
#
###########################################################
+def _test():
+ import doctest, Cookie
+ return doctest.testmod(Cookie)
+
+if __name__ == "__main__":
+ _test()
#Local Variables: