Beispiel #1
0
 def _search_valued_enum(self, codefile_relpath, line_number, l):
     m = self.enumdef_regex.match(l)
     if m is None:
         return None
     enumname = m.group(1)
     enumvalue = int(m.group(2))
     return EnumElement(enumname, codefile_relpath, line_number, enumvalue)
Beispiel #2
0
def test_Incrementer_positive_3():
    d = [
        EnumElement("enum0", "00.txt", 0),
        EnumElement("enum1", "01.txt", 1, 3),
        EnumElement("enum2", "02.txt", 2),
    ]
    assigner = Incrementer(2, 3)
    assigner(d)
    assert d == [
        EnumElement("enum0", "00.txt", 0, 5),
        EnumElement("enum1", "01.txt", 1, 3),
        EnumElement("enum2", "02.txt", 2, 8),
    ]
Beispiel #3
0
def test_Incrementer_negative_1():
    d = [
        EnumElement("enum0", "00.txt", 0),
        EnumElement("enum1", "01.txt", 1),
        EnumElement("enum2", "02.txt", 2),
    ]
    assigner = Incrementer(-1, -1)
    assigner(d)
    assert d == [
        EnumElement("enum0", "00.txt", 0, -1),
        EnumElement("enum1", "01.txt", 1, -2),
        EnumElement("enum2", "02.txt", 2, -3),
    ]
Beispiel #4
0
    "f1/output.5.txt",
    "f1/input.6.png",
    "f2/a/input.7.txt",
    "f2/b/input.8.txt",
    "f2/c/input.9.txt",
)

# all files except f2/c/input.9.txt + folder count (f1, f2, f2/{a, b, c})
_EXPECT_CODEPATH_CHECKS = len(_MOCK_FILES) - 1 + 5

# number of *.txt files
_EXPECT_OUTPUT_CHECKS = 6

_MOCK_ENUMELEMENTS = {
    "input.1.txt": (
        EnumElement("enum1", "input.1.txt", 11),
        EnumElement("enum2", "input.1.txt", 12),
    ),
    "input.2.txt": (EnumElement("enum2", "input.2.txt", 2), ),
    "input.4.txt": (),
    "input.7.txt": (EnumElement("enum3", "input.7.txt", 70), ),
    "input.8.txt": (
        EnumElement("enum1", "input.8.txt", 1, -5),
        EnumElement("enum0", "input.8.txt", 2),
    ),
    "output.5.txt": (
        EnumElement("enum1", "output.5.txt", 1, -3),
        EnumElement("enum2", "output.5.txt", 2, -6),
        EnumElement("enum9", "output.5.txt", 3, -4),
    ),
}
Beispiel #5
0
 def _extract_unvalue_enum(self, codefile_relpath, line_number, l, m):
     s = m.start(1) - 1
     if (s >= 0) and (l[s] in _IDENTIFIER_CHARS):
         return None
     enumname = m.group(1)
     return EnumElement(enumname, codefile_relpath, line_number)
Beispiel #6
0
def enumelem_banana_3b():
    return EnumElement("banana", "f2x2", 61, 3)
Beispiel #7
0
def enumelem_apple_n():
    return EnumElement("apple", "f1", 31)
Beispiel #8
0
def enumelem_banana_nb():
    return EnumElement("banana", "f2b", 53)
Beispiel #9
0
def enumelem_banana_na():
    return EnumElement("banana", "f2a", 52)
Beispiel #10
0
def enumelem_banana_1():
    return EnumElement("banana", "f2", 52, 2)
Beispiel #11
0
def enumelem_apple_3():
    return EnumElement("apple", "f1_x", 53, 3)
Beispiel #12
0
def enumelem_apple_1():
    return EnumElement("apple", "f1_x", 51, 1)