2021-03-12 22:37:47 +00:00
|
|
|
import os
|
2015-11-27 16:19:19 +00:00
|
|
|
from unittest import TestCase
|
|
|
|
|
|
|
|
from django.template import Engine
|
|
|
|
|
|
|
|
from .utils import TEMPLATE_DIR
|
|
|
|
|
|
|
|
|
|
|
|
class OriginTestCase(TestCase):
|
|
|
|
def setUp(self):
|
|
|
|
self.engine = Engine(dirs=[TEMPLATE_DIR])
|
|
|
|
|
|
|
|
def test_origin_compares_equal(self):
|
2022-02-03 19:24:19 +00:00
|
|
|
a = self.engine.get_template("index.html")
|
|
|
|
b = self.engine.get_template("index.html")
|
2015-11-27 16:19:19 +00:00
|
|
|
self.assertEqual(a.origin, b.origin)
|
2019-10-21 08:55:05 +00:00
|
|
|
# Use assertIs() to test __eq__/__ne__.
|
|
|
|
self.assertIs(a.origin == b.origin, True)
|
|
|
|
self.assertIs(a.origin != b.origin, False)
|
2015-11-27 16:19:19 +00:00
|
|
|
|
|
|
|
def test_origin_compares_not_equal(self):
|
2022-02-03 19:24:19 +00:00
|
|
|
a = self.engine.get_template("first/test.html")
|
|
|
|
b = self.engine.get_template("second/test.html")
|
2015-11-27 16:19:19 +00:00
|
|
|
self.assertNotEqual(a.origin, b.origin)
|
2019-10-21 08:55:05 +00:00
|
|
|
# Use assertIs() to test __eq__/__ne__.
|
|
|
|
self.assertIs(a.origin == b.origin, False)
|
|
|
|
self.assertIs(a.origin != b.origin, True)
|
2021-03-12 22:37:47 +00:00
|
|
|
|
|
|
|
def test_repr(self):
|
2022-02-03 19:24:19 +00:00
|
|
|
a = self.engine.get_template("index.html")
|
|
|
|
name = os.path.join(TEMPLATE_DIR, "index.html")
|
|
|
|
self.assertEqual(repr(a.origin), "<Origin name=%r>" % name)
|