# Path: tests/utils.py
# class TemplateTestCase(unittest.TestCase):
#     @classmethod
#     def setUpClass(cls):
#         cls.loader = loader.TemplateLoader([
#             pathlib.Path(__file__).parent / 'templates',
#         ])
# 
#     def assertRendered(self, source, expected, context=None):
#         try:
#             tmpl = compiler.kompile(source, loader=self.loader)
#             rendered = tmpl({} if context is None else context)
#             self.assertEqual(rendered, expected)
#         except Exception as e:
#             if hasattr(e, 'message'):
#                 standardMsg = e.message
#             elif hasattr(e, 'args') and len(e.args) > 0:
#                 standardMsg = e.args[0]
#             else:
#                 standardMsg = ''
#             msg = 'Failed rendering template %s:\n%s: %s' % (
#                 source, e.__class__.__name__, standardMsg)
#             self.fail(msg)
# 
# class Mock(object):
#     def __init__(self, **kwargs):
#         for k, v in kwargs.items():
#             setattr(self, k, v)


from .utils import TemplateTestCase, Mock
        )
        for src, expect in TESTS:
            self.assertRendered(src, expect)


class VariableSyntaxTest(TemplateTestCase):

    def test_direct(self):
        # A list of (template, context, output)
        TESTS = (
            ('{{ a }}', {'a': 'yes'}, 'yes'),
        )
        for src, ctx, expect in TESTS:
            self.assertRendered(src, expect, ctx)

    def test_index(self):
        # A list of (template, context, output)
        TESTS = (
            ('{{ a[1] }}', {'a': ['yes', 'no']}, 'no'),
            ('{{ a["b"] }}', {'a': {'b': 'yes'}}, 'yes'),
            ('{{ a[c] }}', {'a': {'b': 'yes', 'c': 'no'}, 'c': 'b'}, 'yes'),
        )
        for src, ctx, expect in TESTS:
            self.assertRendered(src, expect, ctx)

    def test_attribute(self):
        # A list of (template, context, output)
        TESTS = (
            ('{{ a.b }}', {'a': Mock(b=1)}, '1'),
            ('{{ a.b.c }}', {'a': Mock(b=Mock(c=1))}, '1'),

# Path: tests/utils.py
# class TemplateTestCase(unittest.TestCase):
#     @classmethod
#     def setUpClass(cls):
#         cls.loader = loader.TemplateLoader([
#             pathlib.Path(__file__).parent / 'templates',
#         ])
# 
#     def assertRendered(self, source, expected, context=None):
#         try:
#             tmpl = compiler.kompile(source, loader=self.loader)
#             rendered = tmpl({} if context is None else context)
#             self.assertEqual(rendered, expected)
#         except Exception as e:
#             if hasattr(e, 'message'):
#                 standardMsg = e.message
#             elif hasattr(e, 'args') and len(e.args) > 0:
#                 standardMsg = e.args[0]
#             else:
#                 standardMsg = ''
#             msg = 'Failed rendering template %s:\n%s: %s' % (
#                 source, e.__class__.__name__, standardMsg)
#             self.fail(msg)
# 
# class Mock(object):
#     def __init__(self, **kwargs):
#         for k, v in kwargs.items():
#             setattr(self, k, v)


# Path: tests/test_var.py
from .utils import TemplateTestCase, Mock

        )
        for src, expect in TESTS:
            self.assertRendered(src, expect)


class VariableSyntaxTest(TemplateTestCase):

    def test_direct(self):
        # A list of (template, context, output)
        TESTS = (
            ('{{ a }}', {'a': 'yes'}, 'yes'),
        )
        for src, ctx, expect in TESTS:
            self.assertRendered(src, expect, ctx)

    def test_index(self):
        # A list of (template, context, output)
        TESTS = (
            ('{{ a[1] }}', {'a': ['yes', 'no']}, 'no'),
            ('{{ a["b"] }}', {'a': {'b': 'yes'}}, 'yes'),
            ('{{ a[c] }}', {'a': {'b': 'yes', 'c': 'no'}, 'c': 'b'}, 'yes'),
        )
        for src, ctx, expect in TESTS:
            self.assertRendered(src, expect, ctx)

    def test_attribute(self):
        # A list of (template, context, output)
        TESTS = (
            ('{{ a.b }}', {'a': Mock(b=1)}, '1'),
            ('{{ a.b.c }}', {'a': Mock(b=Mock(c=1))}, '1'),

            ('{{ a["b"].c }}', {'a': {'b': Mock(c=1)}}, '1'),