jw-python/test/parse_opts/test.py
Jan Lindemann 26f3893579
test: Fix MyPy errors
Fix multiple errors in test dug up by MyPy.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-08-12 23:10:12 +00:00

34 lines
1 KiB
Python

from jw.util.log import NOTICE, slog
from jw.util.Options import Options
i: str | int
delim = "======================= "
d = "----------------------- "
s = "this=that a=b doit"
slog(NOTICE, d + s)
a = Options(s)
slog(NOTICE, d + "dump()")
a.dump(NOTICE)
slog(NOTICE, d + "by index")
for i in range(0, 4):
slog(NOTICE, "attr({}) = {}".format(i, a.get(i, by_index = True, default = False)))
slog(NOTICE, d + "by key")
for i in ["this", "that", "b", "a", "doit"]:
slog(NOTICE, "attr({}) = {}".format(i, a[i]))
s = '"me": "too", "Pfalse": true, "myarr": ["a", "b", "c"], "me": "not"'
slog(NOTICE, delim + s)
a = Options(s)
slog(NOTICE, d + "dump()")
a.dump(NOTICE)
slog(NOTICE, d + "by index")
for i in range(0, 5):
slog(NOTICE, "attr({}) = {}".format(i, a.get(i, by_index = True, default = False)))
slog(NOTICE, d + "by key in keys()")
for i in a.keys():
slog(NOTICE, "attr({}) = {}".format(i, a[i]))
slog(NOTICE, d + "by key")
for i in ["me", "Pfalse", "myarr"]:
slog(NOTICE, "attr({}) = {}".format(i, a[i]))