diff --git a/src/apps/homework/models/answer.py b/src/apps/homework/models/answer.py index 9d93f8c39d3..67ded6ece9b 100644 --- a/src/apps/homework/models/answer.py +++ b/src/apps/homework/models/answer.py @@ -92,6 +92,9 @@ class Meta: ] def __str__(self) -> str: + if self.text.startswith("![]"): + return "Картинка" + text = remove_html(markdownify(self.text)) try: first_word = text.split()[0] diff --git a/src/apps/homework/tests/homework/answers/tests_answer_str.py b/src/apps/homework/tests/homework/answers/tests_answer_str.py index f49d7994119..9e065b9bd1e 100644 --- a/src/apps/homework/tests/homework/answers/tests_answer_str.py +++ b/src/apps/homework/tests/homework/answers/tests_answer_str.py @@ -43,6 +43,12 @@ def test_html(mixer): assert str(answer) == "Банзай!" +def test_image(mixer): + answer = mixer.blend("homework.Answer", text="![](https://cdn.tough-dev.school/typicalmacuser.jpg)") + + assert str(answer) == "Картинка" + + def test_zero_length(mixer): answer = mixer.blend("homework.Answer", text="")