Advertisement
IgorGal

Untitled

Jan 22nd, 2020
702
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.29 KB | None | 0 0
  1. $ pytest
  2. ============================= test session starts =============================
  3. 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
  4. django: settings: yatube.settings (from ini)
  5. rootdir: E:\Dev\yatube\hw02_community, inifile: pytest.ini
  6. plugins: django-3.8.0
  7. collecting ... collected 6 items
  8.  
  9. test_homework.py::TestPost::test_post_create PASSED                      [ 16%]
  10. test_homework.py::TestGroup::test_group_create PASSED                    [ 33%]
  11. test_homework.py::TestGroupView::test_group_view FAILED                  [ 50%]
  12. test_homework.py::TestPost::test_post_model PASSED                       [ 66%]
  13. test_homework.py::TestPost::test_post_admin PASSED                       [ 83%]
  14. test_homework.py::TestGroup::test_group_model PASSED                     [100%]
  15.  
  16. ================================== FAILURES ===================================
  17. ________________________ TestGroupView.test_group_view ________________________
  18.  
  19. self = <test_homework.TestGroupView object at 0x00000207FA9EA340>
  20. client = <django.test.client.Client object at 0x00000207FA9FBCD0>
  21. post_with_group = <Post: Post object (3)>
  22.  
  23.     @pytest.mark.django_db(transaction=True)
  24.     def test_group_view(self, client, post_with_group):
  25.         try:
  26.             response = client.get(f'/group/{post_with_group.group.slug}')
  27.         except Exception as e:
  28.             assert False, f'''Страница `/group/<slug>/` работает неправильно. Ошибка: `{e}`'''
  29.         if response.status_code in (301, 302):
  30.             response = client.get(f'/group/{post_with_group.group.slug}/')
  31.         if response.status_code == 404:
  32.             assert False, 'Страница `/group/<slug>/` не найдена, проверьте этот адрес в *urls.py*'
  33.  
  34.         if response.status_code != 200:
  35.             assert False, 'Страница `/group/<slug>/` работает неправильно.'
  36.         group = post_with_group.group
  37.         html = response.content.decode()
  38.  
  39.         html_template = get_template('group.html').template.source
  40.  
  41.         assert search_refind(r'{%\s*for\s+.+in.*%}', html_template), \
  42.             'Отредактируйте HTML-шаблон, используйте тег цикла'
  43.         assert search_refind(r'{%\s*endfor\s*%}', html_template), \
  44.             'Отредактируйте HTML-шаблон, не найден тег закрытия цикла'
  45.  
  46.         assert re.search(
  47.             r'<\s*title\s*>\s*Записи\s+сообщества\s+' + group.title + r'\s+\|\s+Yatube\s*<\s*\/title\s*>',
  48.             html
  49.         ), 'Отредактируйте HTML-шаблон, не найдено название страницы `<title>Записи сообщества {{ название_группы }} | Yatube</title>`'
  50.         assert re.search(
  51.             r'<\s*h1\s*>\s*' + group.title + r'\s*<\s*\/h1\s*>',
  52.             html
  53.         ), 'Отредактируйте HTML-шаблон, не найден заголовок группы `<h1>{{ название_группы }}</h1>`'
  54. >       assert re.search(
  55.             r'<\s*p\s*>\s*' + group.description + r'\s*<\s*\/p\s*>',
  56.             html
  57.         ), 'Отредактируйте HTML-шаблон, не найдено описание группы `<p>{{ описание_группы }}</p>`'
  58. E       AssertionError: Отредактируйте HTML-шаблон, не найдено описание группы `<p>{{ описание_группы }}</p>`
  59. E       assert None
  60. 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>')
  61. E        +    where <function search at 0x00000207F807E040> = re.search
  62. E        +    and   'Тестовое описание группы' = <Group: Тестовая группа 1>.description
  63.  
  64. test_homework.py:183: AssertionError
  65. ========================= 1 failed, 5 passed in 0.74s =========================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement