def test_cannot_init(self): with self.assertRaises(TypeError): Literal() with self.assertRaises(TypeError): Literal[1]() with self.assertRaises(TypeError): type(Literal)() with self.assertRaises(TypeError): type(Literal[1])()
def _define_grammar(): from pyparsing import ( Literal as Literal, Word, Optional, alphas, alphanums, delimitedList, ) Separator = Literal("@").suppress() TagSeparator = Literal("?").suppress() Name = delimitedList(Word(alphas, alphanums + "_"), PATH_DELIM, combine=True).setResultsName("name") Tag = Word(alphas, alphanums + "_").setResultsName("tag") Selector = _selector_grammar.setResultsName("selector") SelectorType = (Literal("solids") | Literal("faces") | Literal("edges") | Literal("vertices")).setResultsName("selector_kind") return (Name + Optional(TagSeparator + Tag) + Optional(Separator + SelectorType + Separator + Selector))