Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_iterate_marked(cfg):
assert list(_iterate_marked(cfg, ConfigSummary())) == [
("a", ConfigEntry("a", 0, False, False, None, None)),
("b", ConfigEntry("b", {}, False, False, None, None)),
("c", PathEntry("c", False, False, None, None)),
("c.cA", ConfigEntry("cA", 3, False, False, None, None)),
("c.cB", ConfigEntry("cB", 4, False, False, None, None)),
("c.cC", PathEntry("cC", False, False, None, None)),
("c.cC.cC1", ConfigEntry("cC1", 6, False, False, None, None)),
("d", PathEntry("d", False, False, None, None)),
("d.dA", ConfigEntry("dA", 8, False, False, None, None)),
]
def test_iterate_marked_typechanged(cfg):
typechanged = {"a": (bool, int), "d.dA": (float, int)}
result = list(_iterate_marked(cfg, ConfigSummary(typechanged=typechanged)))
assert result == [
("a", ConfigEntry("a", 0, False, False, (bool, int), None)),
("b", ConfigEntry("b", {}, False, False, None, None)),
("c", PathEntry("c", False, False, None, None)),
("c.cA", ConfigEntry("cA", 3, False, False, None, None)),
("c.cB", ConfigEntry("cB", 4, False, False, None, None)),
("c.cC", PathEntry("cC", False, False, None, None)),
("c.cC.cC1", ConfigEntry("cC1", 6, False, False, None, None)),
("d", PathEntry("d", False, True, None, None)),
("d.dA", ConfigEntry("dA", 8, False, False, (float, int), None)),
]
def test_iterate_marked_updated(cfg):
modified = {"b", "c", "c.cC.cC1"}
assert list(_iterate_marked(cfg, ConfigSummary(modified=modified))) == [
("a", ConfigEntry("a", 0, False, False, None, None)),
("b", ConfigEntry("b", {}, False, True, None, None)),
("c", PathEntry("c", False, True, None, None)),
("c.cA", ConfigEntry("cA", 3, False, False, None, None)),
("c.cB", ConfigEntry("cB", 4, False, False, None, None)),
("c.cC", PathEntry("cC", False, True, None, None)),
("c.cC.cC1", ConfigEntry("cC1", 6, False, True, None, None)),
("d", PathEntry("d", False, False, None, None)),
("d.dA", ConfigEntry("dA", 8, False, False, None, None)),
]
def test_iterate_marked_updated(cfg):
modified = {"b", "c", "c.cC.cC1"}
assert list(_iterate_marked(cfg, ConfigSummary(modified=modified))) == [
("a", ConfigEntry("a", 0, False, False, None, None)),
("b", ConfigEntry("b", {}, False, True, None, None)),
("c", PathEntry("c", False, True, None, None)),
("c.cA", ConfigEntry("cA", 3, False, False, None, None)),
("c.cB", ConfigEntry("cB", 4, False, False, None, None)),
("c.cC", PathEntry("cC", False, True, None, None)),
("c.cC.cC1", ConfigEntry("cC1", 6, False, True, None, None)),
("d", PathEntry("d", False, False, None, None)),
("d.dA", ConfigEntry("dA", 8, False, False, None, None)),
]
def test_iterate_marked_updated(cfg):
modified = {"b", "c", "c.cC.cC1"}
assert list(_iterate_marked(cfg, ConfigSummary(modified=modified))) == [
("a", ConfigEntry("a", 0, False, False, None, None)),
("b", ConfigEntry("b", {}, False, True, None, None)),
("c", PathEntry("c", False, True, None, None)),
("c.cA", ConfigEntry("cA", 3, False, False, None, None)),
("c.cB", ConfigEntry("cB", 4, False, False, None, None)),
("c.cC", PathEntry("cC", False, True, None, None)),
("c.cC.cC1", ConfigEntry("cC1", 6, False, True, None, None)),
("d", PathEntry("d", False, False, None, None)),
("d.dA", ConfigEntry("dA", 8, False, False, None, None)),
]
def test_iterate_marked_typechanged(cfg):
typechanged = {"a": (bool, int), "d.dA": (float, int)}
result = list(_iterate_marked(cfg, ConfigSummary(typechanged=typechanged)))
assert result == [
("a", ConfigEntry("a", 0, False, False, (bool, int), None)),
("b", ConfigEntry("b", {}, False, False, None, None)),
("c", PathEntry("c", False, False, None, None)),
("c.cA", ConfigEntry("cA", 3, False, False, None, None)),
("c.cB", ConfigEntry("cB", 4, False, False, None, None)),
("c.cC", PathEntry("cC", False, False, None, None)),
("c.cC.cC1", ConfigEntry("cC1", 6, False, False, None, None)),
("d", PathEntry("d", False, True, None, None)),
("d.dA", ConfigEntry("dA", 8, False, False, (float, int), None)),
]
def test_iterate_marked(cfg):
assert list(_iterate_marked(cfg, ConfigSummary())) == [
("a", ConfigEntry("a", 0, False, False, None, None)),
("b", ConfigEntry("b", {}, False, False, None, None)),
("c", PathEntry("c", False, False, None, None)),
("c.cA", ConfigEntry("cA", 3, False, False, None, None)),
("c.cB", ConfigEntry("cB", 4, False, False, None, None)),
("c.cC", PathEntry("cC", False, False, None, None)),
("c.cC.cC1", ConfigEntry("cC1", 6, False, False, None, None)),
("d", PathEntry("d", False, False, None, None)),
("d.dA", ConfigEntry("dA", 8, False, False, None, None)),
]
(ConfigEntry("e", {}, False, False, None, None), "e = {}"),
# Path entries
(PathEntry("f", False, False, None, None), "f:"),
# Docstring entry
(
ConfigEntry("__doc__", "multiline\ndocstring", False, False, None, None),
COLOR_DOC + '"""multiline\ndocstring"""' + ENDC,
),
],
)
def test_format_entry(entry, expected):
assert _format_entry(0, entry) == expected
def test_iterate_marked(cfg):
assert list(_iterate_marked(cfg, ConfigSummary())) == [
("a", ConfigEntry("a", 0, False, False, None, None)),
("b", ConfigEntry("b", {}, False, False, None, None)),
("c", PathEntry("c", False, False, None, None)),
("c.cA", ConfigEntry("cA", 3, False, False, None, None)),
("c.cB", ConfigEntry("cB", 4, False, False, None, None)),
("c.cC", PathEntry("cC", False, False, None, None)),
("c.cC.cC1", ConfigEntry("cC1", 6, False, False, None, None)),
("d", PathEntry("d", False, False, None, None)),
("d.dA", ConfigEntry("dA", 8, False, False, None, None)),
]
(ConfigEntry("c", True, False, False, None, None), "c = True"),
(ConfigEntry("d", 0.5, False, False, None, None), "d = 0.5"),
(ConfigEntry("e", {}, False, False, None, None), "e = {}"),
# Path entries
(PathEntry("f", False, False, None, None), "f:"),
# Docstring entry
(
ConfigEntry("__doc__", "multiline\ndocstring", False, False, None, None),
COLOR_DOC + '"""multiline\ndocstring"""' + ENDC,
),
],
)
def test_format_entry(entry, expected):
assert _format_entry(0, entry) == expected