File: test_find_template.py

package info (click to toggle)
python-django-extensions 4.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,812 kB
  • sloc: python: 18,601; javascript: 7,354; makefile: 108; xml: 17
file content (20 lines) | stat: -rw-r--r-- 680 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
# -*- coding: utf-8 -*-
from django.core.management import call_command
from django.test import TestCase
from io import StringIO

from unittest.mock import patch


class FindTemplateTests(TestCase):
    @patch("sys.stdout", new_callable=StringIO)
    def test_finding_template(self, m_stdout):
        call_command("find_template", "admin/change_form.html")

        self.assertIn("admin/change_form.html", m_stdout.getvalue())

    @patch("sys.stderr", new_callable=StringIO)
    def test_should_print_error_when_template_not_found(self, m_stderr):
        call_command("find_template", "not_found_template.html")

        self.assertIn("No template found", m_stderr.getvalue())