File: test_templatetags.py

package info (click to toggle)
python-django-extensions 4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,820 kB
  • sloc: python: 18,601; javascript: 7,354; makefile: 108; xml: 17
file content (40 lines) | stat: -rw-r--r-- 1,190 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# -*- coding: utf-8 -*-
from django.template import engines
from django.test import TestCase

from django_extensions.templatetags.widont import widont, widont_html

from unittest.mock import MagicMock


# TODO: these tests are far from having decent test coverage
class TemplateTagsTests(TestCase):
    def test_widont(self):
        self.assertEqual(widont("Test Value"), "Test Value")
        self.assertEqual(widont(str("Test Value")), str("Test Value"))

    def test_widont_html(self):
        self.assertEqual(widont_html("Test Value"), "Test Value")
        self.assertEqual(widont_html(str("Test Value")), str("Test Value"))


class DebuggerTagsTests(TestCase):
    """Test class for DebuggerTags."""

    def setUp(self):
        self.engine = engines["django"]

    def test_pdb_filter(self):
        """Test for pdb filter."""
        import pdb

        pdb.set_trace = MagicMock(return_value=None)
        template = self.engine.from_string(
            """
            {% load debugger_tags %}

            {{ test_object|pdb }}
            """
        )
        template.render({"test_object": "test_value"})
        self.assertTrue(pdb.set_trace.called)