File: test_debug.py

package info (click to toggle)
python-django 3%3A3.2.19-1%2Bdeb12u2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 56,696 kB
  • sloc: python: 264,418; javascript: 18,362; xml: 193; makefile: 178; sh: 43
file content (46 lines) | stat: -rw-r--r-- 1,534 bytes parent folder | download | duplicates (2)
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
41
42
43
44
45
46
from django.contrib.auth.models import Group
from django.test import SimpleTestCase, override_settings

from ..utils import setup


@override_settings(DEBUG=True)
class DebugTests(SimpleTestCase):

    @override_settings(DEBUG=False)
    @setup({'non_debug': '{% debug %}'})
    def test_non_debug(self):
        output = self.engine.render_to_string('non_debug', {})
        self.assertEqual(output, '')

    @setup({'modules': '{% debug %}'})
    def test_modules(self):
        output = self.engine.render_to_string('modules', {})
        self.assertIn(
            ''django': <module 'django' ',
            output,
        )

    @setup({'plain': '{% debug %}'})
    def test_plain(self):
        output = self.engine.render_to_string('plain', {'a': 1})
        self.assertTrue(output.startswith(
            '{'a': 1}'
            '{'False': False, 'None': None, '
            ''True': True}\n\n{'
        ))

    @setup({'non_ascii': '{% debug %}'})
    def test_non_ascii(self):
        group = Group(name="清風")
        output = self.engine.render_to_string('non_ascii', {'group': group})
        self.assertTrue(output.startswith(
            '{'group': <Group: 清風>}'
        ))

    @setup({'script': '{% debug %}'})
    def test_script(self):
        output = self.engine.render_to_string('script', {'frag': '<script>'})
        self.assertTrue(output.startswith(
            '{&#x27;frag&#x27;: &#x27;&lt;script&gt;&#x27;}'
        ))