Beispiel #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))
         ]
Beispiel #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)),
    ]
Beispiel #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))
         ]
Beispiel #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))
         ]
Beispiel #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)),
    ]
Beispiel #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))
         ]
Beispiel #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)),
    ]
Beispiel #8
0
        [('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))
         ]


@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

Beispiel #9
0
    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))
         ]


@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

Beispiel #10
0
        ("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)),
    ]


@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,
        ),
    ],
)