Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ pytest
- ============================= test session starts =============================
- platform win32 -- Python 3.8.1, pytest-5.3.4, py-1.8.1, pluggy-0.13.1 -- c:\users\myseo\appdata\local\programs\python\python38\python.exe
- django: settings: yatube.settings (from ini)
- rootdir: E:\Dev\yatube\hw02_community, inifile: pytest.ini
- plugins: django-3.8.0
- collecting ... collected 6 items
- test_homework.py::TestPost::test_post_create PASSED [ 16%]
- test_homework.py::TestGroup::test_group_create PASSED [ 33%]
- test_homework.py::TestGroupView::test_group_view FAILED [ 50%]
- test_homework.py::TestPost::test_post_model PASSED [ 66%]
- test_homework.py::TestPost::test_post_admin PASSED [ 83%]
- test_homework.py::TestGroup::test_group_model PASSED [100%]
- ================================== FAILURES ===================================
- ________________________ TestGroupView.test_group_view ________________________
- self = <test_homework.TestGroupView object at 0x00000207FA9EA340>
- client = <django.test.client.Client object at 0x00000207FA9FBCD0>
- post_with_group = <Post: Post object (3)>
- @pytest.mark.django_db(transaction=True)
- def test_group_view(self, client, post_with_group):
- try:
- response = client.get(f'/group/{post_with_group.group.slug}')
- except Exception as e:
- assert False, f'''Страница `/group/<slug>/` работает неправильно. Ошибка: `{e}`'''
- if response.status_code in (301, 302):
- response = client.get(f'/group/{post_with_group.group.slug}/')
- if response.status_code == 404:
- assert False, 'Страница `/group/<slug>/` не найдена, проверьте этот адрес в *urls.py*'
- if response.status_code != 200:
- assert False, 'Страница `/group/<slug>/` работает неправильно.'
- group = post_with_group.group
- html = response.content.decode()
- html_template = get_template('group.html').template.source
- assert search_refind(r'{%\s*for\s+.+in.*%}', html_template), \
- 'Отредактируйте HTML-шаблон, используйте тег цикла'
- assert search_refind(r'{%\s*endfor\s*%}', html_template), \
- 'Отредактируйте HTML-шаблон, не найден тег закрытия цикла'
- assert re.search(
- r'<\s*title\s*>\s*Записи\s+сообщества\s+' + group.title + r'\s+\|\s+Yatube\s*<\s*\/title\s*>',
- html
- ), 'Отредактируйте HTML-шаблон, не найдено название страницы `<title>Записи сообщества {{ название_группы }} | Yatube</title>`'
- assert re.search(
- r'<\s*h1\s*>\s*' + group.title + r'\s*<\s*\/h1\s*>',
- html
- ), 'Отредактируйте HTML-шаблон, не найден заголовок группы `<h1>{{ название_группы }}</h1>`'
- > assert re.search(
- r'<\s*p\s*>\s*' + group.description + r'\s*<\s*\/p\s*>',
- html
- ), 'Отредактируйте HTML-шаблон, не найдено описание группы `<p>{{ описание_группы }}</p>`'
- E AssertionError: Отредактируйте HTML-шаблон, не найдено описание группы `<p>{{ описание_группы }}</p>`
- E assert None
- E + where None = <function search at 0x00000207F807E040>((('<\\s*p\\s*>\\s*' + 'Тестовое описание группы') + '\\s*<\\s*\\/p\\s*>'), '<!doctype html>\n<html>\n <head>\n <meta charset="utf-8">\n <meta name="viewport" content="width=dev...20\n </h3>\n <p>Тестовый пост 2</p>\n <hr>\n \n\n\n </div>\n </main>\n\n</body>\n</html>')
- E + where <function search at 0x00000207F807E040> = re.search
- E + and 'Тестовое описание группы' = <Group: Тестовая группа 1>.description
- test_homework.py:183: AssertionError
- ========================= 1 failed, 5 passed in 0.74s =========================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement