# 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)


import pathlib
from .utils import TemplateTestCase, Mock

    def test_for_empty_false(self):
        self.assertRendered(
            '{% for a, b in seq %}{{ a }} == {{ b }},{% empty %}empty{% endfor %}',
            'a == 1,b == 2,',
            {'seq': (('a', 1), ('b', 2))},
        )

    def test_for_empty_true(self):
        self.assertRendered(
            '{% for a, b in seq %}{{ a }} == {{ b }},{% empty %}empty{% endfor %}',
            'empty',
            {'seq': ()},
        )

    def test_scope(self):
        self.assertRendered(
            '{% for a in seq %}{{ a * b }} {% endfor %}',
            '2 4 6 ',
            {'seq': (1, 2, 3), 'b': 2},
        )

    def test_attr_source(self):
        self.assertRendered(
            '{% for a in obj.seq %}{{ a }}{% endfor %}',
            '1234',
            {'obj': Mock(seq=[1, 2, 3, 4])},
        )



# 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_blocks.py
import pathlib
from .utils import TemplateTestCase, Mock


    def test_for_empty_false(self):
        self.assertRendered(
            '{% for a, b in seq %}{{ a }} == {{ b }},{% empty %}empty{% endfor %}',
            'a == 1,b == 2,',
            {'seq': (('a', 1), ('b', 2))},
        )

    def test_for_empty_true(self):
        self.assertRendered(
            '{% for a, b in seq %}{{ a }} == {{ b }},{% empty %}empty{% endfor %}',
            'empty',
            {'seq': ()},
        )

    def test_scope(self):
        self.assertRendered(
            '{% for a in seq %}{{ a * b }} {% endfor %}',
            '2 4 6 ',
            {'seq': (1, 2, 3), 'b': 2},
        )

    def test_attr_source(self):
        self.assertRendered(
            '{% for a in obj.seq %}{{ a }}{% endfor %}',
            '1234',
            {'obj': Mock(seq=[1, 2, 3, 4])},
        )



class IfTagTest(TemplateTestCase):