diff options
author | Moshe Zadka <moshez@math.huji.ac.il> | 2000-08-25 21:47:56 (GMT) |
---|---|---|
committer | Moshe Zadka <moshez@math.huji.ac.il> | 2000-08-25 21:47:56 (GMT) |
commit | a1a4b5916b08b24ac0f326949f6d0a0a3cedb963 (patch) | |
tree | 56facd35f1d910d71d385d9dc166c811b82a11b4 /Lib/test/test_cgi.py | |
parent | dc3d606bd931bc7ffa780bd397ca184f69bb3838 (diff) | |
download | cpython-a1a4b5916b08b24ac0f326949f6d0a0a3cedb963.zip cpython-a1a4b5916b08b24ac0f326949f6d0a0a3cedb963.tar.gz cpython-a1a4b5916b08b24ac0f326949f6d0a0a3cedb963.tar.bz2 |
Closing patch #101120 -- After everyone agreed.
Diffstat (limited to 'Lib/test/test_cgi.py')
-rw-r--r-- | Lib/test/test_cgi.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/Lib/test/test_cgi.py b/Lib/test/test_cgi.py index 61c3da7..29eb5a6 100644 --- a/Lib/test/test_cgi.py +++ b/Lib/test/test_cgi.py @@ -116,19 +116,27 @@ def main(): d = do_test(orig, "POST") assert d == expect, "Error parsing %s" % repr(orig) - d = {'QUERY_STRING': orig} - fcd = cgi.FormContentDict(d) - sd = cgi.SvFormContentDict(d) + env = {'QUERY_STRING': orig} + fcd = cgi.FormContentDict(env) + sd = cgi.SvFormContentDict(env) + fs = cgi.FieldStorage(environ=env) if type(expect) == type({}): # test dict interface assert len(expect) == len(fcd) assert norm(expect.keys()) == norm(fcd.keys()) assert norm(expect.values()) == norm(fcd.values()) assert norm(expect.items()) == norm(fcd.items()) + assert fcd.get("nonexistent field", "default") == "default" + assert len(sd) == len(fs) + assert norm(sd.keys()) == norm(fs.keys()) + assert fs.getvalue("nonexistent field", "default") == "default" + # test individual fields for key in expect.keys(): expect_val = expect[key] assert fcd.has_key(key) assert norm(fcd[key]) == norm(expect[key]) + assert fcd.get(key, "default") == fcd[key] + assert fs.has_key(key) if len(expect_val) > 1: single_value = 0 else: @@ -137,9 +145,11 @@ def main(): val = sd[key] except IndexError: assert not single_value + assert fs.getvalue(key) == expect_val else: assert single_value assert val == expect_val[0] + assert fs.getvalue(key) == expect_val[0] assert norm(sd.getlist(key)) == norm(expect_val) if single_value: assert norm(sd.values()) == \ |