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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
# -*- coding: utf-8 -*-
import os
from django.core.management import call_command
def test_without_args(capsys, settings):
call_command("notes")
out, err = capsys.readouterr()
assert (
"tests/testapp/file_without_utf8_notes.py:\n * [ 3] TODO this is a test todo\n\n"
in out
)
def test_with_utf8(capsys, settings):
call_command("notes")
out, err = capsys.readouterr()
assert (
"tests/testapp/file_with_utf8_notes.py:\n * [ 3] TODO Russian text followed: Это техт на кириллице\n\n"
in out
)
def test_with_template_dirs(capsys, settings, tmpdir_factory):
templates_dirs_path = tmpdir_factory.getbasetemp().strpath
template_path = os.path.join(templates_dirs_path, "fixme.html")
os.mkdir(os.path.join(templates_dirs_path, "sub.path"))
sub_path = os.path.join(templates_dirs_path, "sub.path", "todo.html")
settings.TEMPLATES[0]["DIRS"] = [templates_dirs_path]
with open(template_path, "w") as f:
f.write(
"""{# FIXME This is a comment. #}
{# TODO Do not show this. #}"""
)
with open(sub_path, "w") as f:
f.write(
"""{# FIXME This is a second comment. #}
{# TODO Do not show this. #}"""
)
call_command("notes", "--tag=FIXME")
out, err = capsys.readouterr()
assert "{}:\n * [ 1] FIXME This is a comment.".format(template_path) in out
assert "{}:\n * [ 1] FIXME This is a second comment.".format(sub_path) in out
assert "TODO Do not show this." not in out
def test_with_template_sub_dirs(capsys, settings, tmpdir_factory):
templates_dirs_path = tmpdir_factory.getbasetemp().strpath
os.mkdir(os.path.join(templates_dirs_path, "test.path"))
template_path = os.path.join(templates_dirs_path, "test.path", "fixme.html")
settings.TEMPLATES[0]["DIRS"] = [templates_dirs_path]
with open(template_path, "w") as f:
f.write(
"""{# FIXME This is a comment. #}
{# TODO Do not show this. #}"""
)
call_command("notes", "--tag=FIXME")
out, err = capsys.readouterr()
assert "{}:\n * [ 1] FIXME This is a comment.".format(template_path) in out
assert "TODO Do not show this." not in out
|