From 33e554b59cc5c8d59775d1e8c69f6bfc698c514e Mon Sep 17 00:00:00 2001 From: "FC (Fay) Stegerman" Date: Thu, 14 Dec 2023 22:07:14 +0100 Subject: [PATCH] fix cookie test --- jiten/app.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/jiten/app.py b/jiten/app.py index 6d54020..9aa52c6 100644 --- a/jiten/app.py +++ b/jiten/app.py @@ -149,13 +149,22 @@ >>> d.index("JLPT N3") < d.index("歯", d.index("JLPT N5")) < d.index("JLPT N2") True ->>> sorted( (c.name, c.value) for c in client.cookie_jar ) +>>> def cookies(): +... import importlib.metadata +... v = tuple(map(int, importlib.metadata.version("werkzeug").split("."))) +... if v < (2, 3): +... return sorted( (c.name, c.value) for c in client.cookie_jar ) +... else: +... cookies = [ client.get_cookie(k) for k in PREFS ] +... return sorted( (c.decoded_key, c.decoded_value) for c in cookies ) + +>>> cookies() [] >>> p = dict(dark = "yes", lang = "eng ger oops".split()) >>> r = client.post("/_save_prefs", data = p, follow_redirects = True) >>> r.status '200 OK' ->>> sorted( (c.name, c.value) for c in client.cookie_jar ) +>>> cookies() [('dark', 'yes'), ('lang', '"eng ger"'), ('large', 'no'), ('max', '50'), ('nogrid', 'no'), ('nor2h', 'no'), ('roma', 'no')] """ # }}}1