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)
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), ]
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), ]
"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), ), }
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)
def enumelem_banana_3b(): return EnumElement("banana", "f2x2", 61, 3)
def enumelem_apple_n(): return EnumElement("apple", "f1", 31)
def enumelem_banana_nb(): return EnumElement("banana", "f2b", 53)
def enumelem_banana_na(): return EnumElement("banana", "f2a", 52)
def enumelem_banana_1(): return EnumElement("banana", "f2", 52, 2)
def enumelem_apple_3(): return EnumElement("apple", "f1_x", 53, 3)
def enumelem_apple_1(): return EnumElement("apple", "f1_x", 51, 1)