Esempio n. 1
0
class BlockBuilderTestCase(unittest.TestCase):
    """ Test the ``BlockBuilder`` blocks.
    """

    def setUp(self):
        from wheezy.template.builder import BlockBuilder
        self.builder = BlockBuilder([])

    def test_start_end_block(self):
        """ Test start_block and end_block.
        """
        self.builder.start_block()
        assert self.builder.indent == '    '
        self.builder.end_block()
        assert self.builder.indent == ''

    def test_unexpected_end_block(self):
        """ Test raises error.
        """
        self.assertRaises(SyntaxError,
                          lambda: self.builder.end_block())

    def test_inconsistence(self):
        """ Test add a line with wrong lineno.
        """
        self.assertRaises(SyntaxError,
                          lambda: self.builder.add(-1, ''))

    def test_unknown_token(self):
        """ Test raises error if token is unknown.
        """
        self.assertRaises(SyntaxError,
                          lambda: self.builder.build_token(1, 'x', None))
Esempio n. 2
0
class BlockBuilderTestCase(unittest.TestCase):
    """ Test the ``BlockBuilder`` blocks.
    """
    def setUp(self):
        from wheezy.template.builder import BlockBuilder
        self.builder = BlockBuilder([])

    def test_start_end_block(self):
        """ Test start_block and end_block.
        """
        self.builder.start_block()
        assert self.builder.indent == '    '
        self.builder.end_block()
        assert self.builder.indent == ''

    def test_unexpected_end_block(self):
        """ Test raises error.
        """
        self.assertRaises(SyntaxError, lambda: self.builder.end_block())

    def test_inconsistence(self):
        """ Test add a line with wrong lineno.
        """
        self.assertRaises(SyntaxError, lambda: self.builder.add(-1, ''))

    def test_unknown_token(self):
        """ Test raises error if token is unknown.
        """
        self.assertRaises(SyntaxError,
                          lambda: self.builder.build_token(1, 'x', None))
Esempio n. 3
0
class BlockBuilderTestCase(unittest.TestCase):
    """Test the ``BlockBuilder`` blocks."""
    def setUp(self) -> None:
        self.builder = BlockBuilder({})

    def test_start_end_block(self) -> None:
        """Test start_block and end_block."""
        self.builder.start_block()
        assert self.builder.indent == "    "
        self.builder.end_block()
        assert self.builder.indent == ""

    def test_unexpected_end_block(self) -> None:
        """Test raises error."""
        self.assertRaises(SyntaxError, lambda: self.builder.end_block())

    def test_inconsistence(self) -> None:
        """Test add a line with wrong lineno."""
        self.assertRaises(SyntaxError, lambda: self.builder.add(-1, ""))

    def test_unknown_token(self) -> None:
        """Test raises error if token is unknown."""
        self.assertRaises(SyntaxError,
                          lambda: self.builder.build_token(1, "x", ""))