diff options
author | Helmut Grohne <helmut@subdivi.de> | 2009-02-27 02:28:31 +0100 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2009-02-27 02:28:31 +0100 |
commit | a3f5b782fded63de63641f3e411301eb6ab96dfb (patch) | |
tree | 42dfb38746a51d9594dbf02c3dd9b5f753f1cd61 /wsgitools | |
parent | f4813885ceaebbf0c37fbca6764019c15950d6e7 (diff) | |
download | wsgitools-a3f5b782fded63de63641f3e411301eb6ab96dfb.tar.gz |
added more doctests for digest module
Diffstat (limited to 'wsgitools')
-rwxr-xr-x | wsgitools/digest.py | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/wsgitools/digest.py b/wsgitools/digest.py index bebb2e2..91ea8cf 100755 --- a/wsgitools/digest.py +++ b/wsgitools/digest.py @@ -22,6 +22,11 @@ def parse_digest_response(data, ret=dict()): {'foo': 'bar'} >>> sorted(parse_digest_response('foo="bar=qux",spam=egg').items()) [('foo', 'bar=qux'), ('spam', 'egg')] + >>> try: + ... parse_digest_response('spam') + ... except ValueError: + ... print "ValueError" + ValueError """ data = data.strip() key, rest = data.split('=', 1) # raises ValueError @@ -129,6 +134,17 @@ class StatelessNonceStore(NonceStoreBase): nonces. This nonce store is usable with L{scgi.forkpool}. + + >>> s = StatelessNonceStore() + >>> n = s.newnonce() + >>> s.checknonce("spam") + False + >>> s.isnonce(n) + True + >>> s.checknonce(n) + True + >>> s.checknonce(n) + True """ def __init__(self, maxage=300, secret=None): """ @@ -206,7 +222,20 @@ class StatelessNonceStore(NonceStoreBase): __all__.append("MemoryNonceStore") class MemoryNonceStore(NonceStoreBase): - """Simple in-memory mechanism to store nonces.""" + """ + Simple in-memory mechanism to store nonces. + + >>> s = MemoryNonceStore(maxuses=1) + >>> n = s.newnonce() + >>> s.checknonce("spam") + False + >>> s.isnonce(n) + True + >>> s.checknonce(n) + True + >>> s.checknonce(n) + False + """ def __init__(self, maxage=300, maxuses=5): """ @type maxage: int |