File: test_validate_templates.py

package info (click to toggle)
python-django-extensions 2.1.4-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,396 kB
  • sloc: python: 11,858; makefile: 116
file content (24 lines) | stat: -rw-r--r-- 707 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
# -*- coding: utf-8 -*-
import pytest
from django.core.management import call_command, CommandError
from django.utils.six import StringIO


def test_validate_templates():
    out = StringIO()
    try:
        call_command('validate_templates', verbosity=3, stdout=out, stderr=out)
    except CommandError:
        print(out.getvalue())
        raise

    output = out.getvalue()
    assert "0 errors found\n" in output


def test_validate_templates_with_error(settings):
    settings.INSTALLED_APPS += ['tests.testapp_with_template_errors']

    out = StringIO()
    with pytest.raises(CommandError, message="1 errors found"):
        call_command('validate_templates', verbosity=3, stdout=out, stderr=out)