Ejemplo n.º 1
0
Archivo: rst.py Proyecto: stsewd/lira
 def _parse_test(self, node):
     attrs = node.attributes
     description = attrs["content"][0]
     options = attrs["options"]
     help = options.get("help", "")
     validator = options["validator"]
     return booknodes.TestBlock(
         validator=validator,
         description=description,
         help=help,
     )
Ejemplo n.º 2
0
 def test_test_block_node(self):
     node = nodes.TestBlock(
         validator="lira.validators.Validator",
         help="Validate me",
         description="I'm a validator",
     )
     assert node.tagname == "TestBlock"
     assert node.options.validator == "lira.validators.Validator"
     assert node.options.help == "Validate me"
     assert node.options.description == "I'm a validator"
     assert node.text() == "I'm a validator"
     assert str(node) == "<TestBlock lira.validators.Validator: I'm a validator>"
Ejemplo n.º 3
0
 def test_test_block_node(self):
     node = nodes.TestBlock(
         ["# Write a comment"],
         validator="lira.validators.Validator",
         language="python",
         state=State.UNKNOWN,
         description="I'm a validator",
         extension=".txt",
     )
     assert node.tagname == "TestBlock"
     assert node.options.validator == "lira.validators.Validator"
     assert node.options.language == "python"
     assert node.options.description == "I'm a validator"
     assert node.options.state == State.UNKNOWN
     assert node.text() == "# Write a comment"
     assert str(node) == "<TestBlock lira.validators.Validator: I'm a validator>"
Ejemplo n.º 4
0
 def _parse_test_block(self, node):
     attrs = node.attributes
     description = attrs["arguments"][0]
     options = attrs["options"]
     validator = options["validator"]
     state = options.get("state", State.UNKNOWN)
     language = options.get("language")
     extension = options.get("extension", guess_extension(language))
     content = list(attrs["content"])
     return booknodes.TestBlock(
         content,
         validator=validator,
         description=description,
         state=state,
         language=language,
         extension=extension,
     )
Ejemplo n.º 5
0
    def test_block_node_reset(self):
        node = nodes.TestBlock(
            ["# Write a comment"],
            validator="lira.validators.Validator",
            language="python",
            state=State.UNKNOWN,
            description="I'm a validator",
            extension=".txt",
        )
        node.options.language = "python"
        node.options.state = State.VALID
        node.options.description = "Please revert me!"
        node.content = ["One", "Two"]

        node.reset()

        assert node.tagname == "TestBlock"
        assert node.options.validator == "lira.validators.Validator"
        assert node.options.language == "python"
        assert node.options.description == "I'm a validator"
        assert node.options.state == State.UNKNOWN
        assert node.text() == "# Write a comment"