Ejemplo n.º 1
0
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))
         ]
Ejemplo n.º 2
0
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)),
    ]
Ejemplo n.º 3
0
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))
         ]
Ejemplo n.º 4
0
def test_iterate_marked_added(cfg):
    added = {'a', 'c.cB', 'c.cC.cC1'}
    assert list(iterate_marked(cfg, ConfigSummary(added=added))) == \
        [('a', ConfigEntry('a', 0, True, False, None)),
         ('b', ConfigEntry('b', {}, False, False, None)),
         ('c', PathEntry('c', False, True, None)),
         ('c.cA', ConfigEntry('cA', 3, False, False, None)),
         ('c.cB', ConfigEntry('cB', 4, True, False, None)),
         ('c.cC', PathEntry('cC', False, True, None)),
         ('c.cC.cC1', ConfigEntry('cC1', 6, True, False, None)),
         ('d', PathEntry('d', False, False, None)),
         ('d.dA', ConfigEntry('dA', 8, False, False, None))
         ]
Ejemplo n.º 5
0
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)),
    ]
Ejemplo n.º 6
0
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))
         ]
Ejemplo n.º 7
0
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)),
    ]
Ejemplo n.º 8
0
         ('d', PathEntry('d', False, True, None, None)),
         ('d.dA', ConfigEntry('dA', 8, False, False, (float, int), None))
         ]


@pytest.mark.parametrize(
    "entry,expected",
    [
        (ConfigEntry('a', 0, False, False, None, None), "a = 0"),
        (ConfigEntry('foo', 'bar', False, False, None, None), "foo = 'bar'"),
        (ConfigEntry('b', [0, 1], False, False, None, None), "b = [0, 1]"),
        (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


@pytest.mark.parametrize(
    "entry,color",
    [
        (ConfigEntry('a', 1, True, False, None, None), COLOR_ADDED),
        (ConfigEntry('b', 2, False, True, None, None), COLOR_MODIFIED),
        (ConfigEntry('c', 3, False, False,
                     (bool, int), None), COLOR_TYPECHANGED),
Ejemplo n.º 9
0
         ('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))
         ]


@pytest.mark.parametrize("entry,expected", [
    (ConfigEntry('a', 0, False, False, None, None),       "a = 0"),
    (ConfigEntry('foo', 'bar', False, False, None, None), "foo = 'bar'"),
    (ConfigEntry('b', [0, 1], False, False, None, None),  "b = [0, 1]"),
    (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),
     GREY + '"""multiline\ndocstring"""' + ENDC),
])
def test_format_entry(entry, expected):
    assert _format_entry(0, entry) == expected


@pytest.mark.parametrize("entry,color", [
    (ConfigEntry('a', 1, True, False, None, None),         GREEN),
    (ConfigEntry('b', 2, False, True, None, None),         BLUE),
    (ConfigEntry('c', 3, False, False, (bool, int), None), RED),
    (ConfigEntry('d', 4, True, True, None, None),          GREEN),
    (ConfigEntry('e', 5, True, False, (bool, int), None),  RED),
    (ConfigEntry('f', 6, False, True, (bool, int), None),  RED),
Ejemplo n.º 10
0
        ("d", PathEntry("d", False, True, None, None)),
        ("d.dA", ConfigEntry("dA", 8, False, False, (float, int), None)),
    ]


@pytest.mark.parametrize(
    "entry,expected",
    [
        (ConfigEntry("a", 0, False, False, None, None), "a = 0"),
        (ConfigEntry("foo", "bar", False, False, None, None), "foo = 'bar'"),
        (ConfigEntry("b", [0, 1], False, False, None, None), "b = [0, 1]"),
        (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


@pytest.mark.parametrize(
    "entry,color",
    [