Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (venv) matakov@MBPD hw05_final % source venv/bin/activate
- (venv) matakov@MBPD hw05_final % pytest
- ================================================================== test session starts ===================================================================
- platform darwin -- Python 3.8.3, pytest-5.3.5, py-1.8.1, pluggy-0.13.1 -- /Users/matakov/Dev/hw05_final/venv/bin/python
- django: settings: yatube.settings (from ini)
- rootdir: /Users/matakov/Dev/hw05_final, inifile: pytest.ini, testpaths: tests/
- plugins: django-3.8.0
- collected 21 items
- tests/test_comment.py::TestComment::test_comment_add_view FAILED [ 4%]
- tests/test_comment.py::TestComment::test_comment_add_auth_view PASSED [ 9%]
- tests/test_follow.py::TestFollow::test_follow_not_auth PASSED [ 14%]
- tests/test_follow.py::TestFollow::test_follow_auth FAILED [ 19%]
- tests/test_homework.py::TestPost::test_post_create PASSED [ 23%]
- tests/test_homework.py::TestGroup::test_group_create PASSED [ 28%]
- tests/test_homework.py::TestGroupView::test_group_view FAILED [ 33%]
- tests/test_new.py::TestNewView::test_new_view_get PASSED [ 38%]
- tests/test_new.py::TestNewView::test_new_view_post PASSED [ 42%]
- tests/test_paginator.py::TestGroupPaginatorView::test_group_paginator_view_get FAILED [ 47%]
- tests/test_paginator.py::TestGroupPaginatorView::test_index_paginator_view_get FAILED [ 52%]
- tests/test_post.py::TestPostView::test_post_view_get PASSED [ 57%]
- tests/test_post.py::TestPostEditView::test_post_edit_view_get PASSED [ 61%]
- tests/test_post.py::TestPostEditView::test_post_edit_view_author_get PASSED [ 66%]
- tests/test_post.py::TestPostEditView::test_post_edit_view_author_post PASSED [ 71%]
- tests/test_profile.py::TestProfileView::test_profile_view_get FAILED [ 76%]
- tests/test_comment.py::TestComment::test_comment_model PASSED [ 80%]
- tests/test_follow.py::TestFollow::test_follow PASSED [ 85%]
- tests/test_homework.py::TestPost::test_post_model PASSED [ 90%]
- tests/test_homework.py::TestPost::test_post_admin PASSED [ 95%]
- tests/test_homework.py::TestGroup::test_group_model PASSED [100%]
- ======================================================================== FAILURES ========================================================================
- ___________________________________________________________ TestComment.test_comment_add_view ____________________________________________________________
- self = <tests.test_comment.TestComment object at 0x10a7aad00>, client = <django.test.client.Client object at 0x10afcd5b0>
- post = <Post: Публикация от 2020-09-05 00:00 автора TestUser создана (Тестовый пост )>
- @pytest.mark.django_db(transaction=True)
- def test_comment_add_view(self, client, post):
- try:
- response = client.get(f'/{post.author.username}/{post.id}/comment')
- except Exception as e:
- assert False, f'''Страница `/<username>/<post_id>/comment/` работает неправильно. Ошибка: `{e}`'''
- if response.status_code in (301, 302) and response.url == f'/{post.author.username}/{post.id}/comment/':
- url = f'/{post.author.username}/{post.id}/comment/'
- else:
- url = f'/{post.author.username}/{post.id}/comment'
- assert response.status_code != 404, \
- 'Страница `/<username>/<post_id>/comment/` не найдена, проверьте этот адрес в *urls.py*'
- > response = client.post(url, data={'text': 'Новый коммент!'})
- tests/test_comment.py:75:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- venv/lib/python3.8/site-packages/django/test/client.py:543: in post
- response = super().post(path, data=data, content_type=content_type, secure=secure, **extra)
- venv/lib/python3.8/site-packages/django/test/client.py:356: in post
- return self.generic('POST', path, post_data, content_type,
- venv/lib/python3.8/site-packages/django/test/client.py:422: in generic
- return self.request(**r)
- venv/lib/python3.8/site-packages/django/test/client.py:503: in request
- raise exc_value
- venv/lib/python3.8/site-packages/django/core/handlers/exception.py:34: in inner
- response = get_response(request)
- venv/lib/python3.8/site-packages/django/core/handlers/base.py:115: in _get_response
- response = self.process_exception_by_middleware(e, request)
- venv/lib/python3.8/site-packages/django/core/handlers/base.py:113: in _get_response
- response = wrapped_callback(request, *callback_args, **callback_kwargs)
- posts/views.py:40: in add_comment
- form.instance.author = request.user
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <django.db.models.fields.related_descriptors.ForwardManyToOneDescriptor object at 0x10a5fc850>
- instance = <[AttributeError("'NoneType' object has no attribute 'date'") raised in repr()] Comment object at 0x10af3fd90>
- value = <SimpleLazyObject: <django.contrib.auth.models.AnonymousUser object at 0x10adef1c0>>
- def __set__(self, instance, value):
- """
- Set the related instance through the forward relation.
- With the example above, when setting ``child.parent = parent``:
- - ``self`` is the descriptor managing the ``parent`` attribute
- - ``instance`` is the ``child`` instance
- - ``value`` is the ``parent`` instance on the right of the equal sign
- """
- # An object must be an instance of the related class.
- if value is not None and not isinstance(value, self.field.remote_field.model._meta.concrete_model):
- > raise ValueError(
- 'Cannot assign "%r": "%s.%s" must be a "%s" instance.' % (
- value,
- instance._meta.object_name,
- self.field.name,
- self.field.remote_field.model._meta.object_name,
- )
- E ValueError: Cannot assign "<SimpleLazyObject: <django.contrib.auth.models.AnonymousUser object at 0x10adef1c0>>": "Comment.author" must be a "User" instance.
- venv/lib/python3.8/site-packages/django/db/models/fields/related_descriptors.py:206: ValueError
- ----------------------------------------------------------------- Captured stdout setup ------------------------------------------------------------------
- Operations to perform:
- Synchronize unmigrated apps: messages, staticfiles
- Apply all migrations: admin, auth, contenttypes, flatpages, posts, sessions, sites, thumbnail
- Synchronizing apps without migrations:
- Creating tables...
- Running deferred SQL...
- Running migrations:
- Applying contenttypes.0001_initial... OK
- Applying auth.0001_initial... OK
- Applying admin.0001_initial... OK
- Applying admin.0002_logentry_remove_auto_add... OK
- Applying admin.0003_logentry_add_action_flag_choices... OK
- Applying contenttypes.0002_remove_content_type_name... OK
- Applying auth.0002_alter_permission_name_max_length... OK
- Applying auth.0003_alter_user_email_max_length... OK
- Applying auth.0004_alter_user_username_opts... OK
- Applying auth.0005_alter_user_last_login_null... OK
- Applying auth.0006_require_contenttypes_0002... OK
- Applying auth.0007_alter_validators_add_error_messages... OK
- Applying auth.0008_alter_user_username_max_length... OK
- Applying auth.0009_alter_user_last_name_max_length... OK
- Applying auth.0010_alter_group_name_max_length... OK
- Applying auth.0011_update_proxy_permissions... OK
- Applying sites.0001_initial... OK
- Applying flatpages.0001_initial... OK
- Applying posts.0001_initial... OK
- Applying posts.0002_auto_20200725_1848... OK
- Applying posts.0003_auto_20200725_1920... OK
- Applying posts.0004_auto_20200725_2002... OK
- Applying posts.0005_auto_20200727_1917... OK
- Applying posts.0006_auto_20200823_1505... OK
- Applying posts.0007_post_image... OK
- Applying posts.0008_comment... OK
- Applying posts.0009_auto_20200904_1952... OK
- Applying posts.0010_follow... OK
- Applying posts.0011_auto_20200905_1612... OK
- Applying sessions.0001_initial... OK
- Applying sites.0002_alter_domain_unique... OK
- Applying thumbnail.0001_initial... OK
- ----------------------------------------------------------------- Captured stderr setup ------------------------------------------------------------------
- Creating test database for alias 'default' ('file:memorydb_default?mode=memory&cache=shared')...
- ------------------------------------------------------------------- Captured log call --------------------------------------------------------------------
- ERROR django.request:log.py:222 Internal Server Error: /TestUser/1/comment
- Traceback (most recent call last):
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
- response = get_response(request)
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 115, in _get_response
- response = self.process_exception_by_middleware(e, request)
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 113, in _get_response
- response = wrapped_callback(request, *callback_args, **callback_kwargs)
- File "/Users/matakov/Dev/hw05_final/posts/views.py", line 40, in add_comment
- form.instance.author = request.user
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/db/models/fields/related_descriptors.py", line 206, in __set__
- raise ValueError(
- ValueError: Cannot assign "<SimpleLazyObject: <django.contrib.auth.models.AnonymousUser object at 0x10adef1c0>>": "Comment.author" must be a "User" instance.
- ______________________________________________________________ TestFollow.test_follow_auth _______________________________________________________________
- self = <tests.test_follow.TestFollow object at 0x10ad3eee0>, user_client = <django.test.client.Client object at 0x10adad1f0>, user = <User: TestUser>
- post = <Post: Публикация от 2020-09-05 00:00 автора TestUser создана (Тестовый пост )>
- @pytest.mark.django_db(transaction=True)
- def test_follow_auth(self, user_client, user, post):
- assert user.follower.count() == 0, 'Проверьте, что правильно считается подписки'
- self.check_url(user_client, f'/{post.author.username}/follow', '/<username>/follow/')
- assert user.follower.count() == 0, 'Проверьте, что нельзя подписаться на самого себя'
- user_1 = get_user_model().objects.create_user(username='TestUser_2344')
- user_2 = get_user_model().objects.create_user(username='TestUser_73485')
- self.check_url(user_client, f'/{user_1.username}/follow', '/<username>/follow/')
- assert user.follower.count() == 1, 'Проверьте, что вы можете подписаться на пользователя'
- self.check_url(user_client, f'/{user_1.username}/follow', '/<username>/follow/')
- assert user.follower.count() == 1, 'Проверьте, что вы можете подписаться на пользователя только один раз'
- image = tempfile.NamedTemporaryFile(suffix=".jpg").name
- Post.objects.create(text='Тестовый пост 4564534', author=user_1, image=image)
- Post.objects.create(text='Тестовый пост 354745', author=user_1, image=image)
- Post.objects.create(text='Тестовый пост 245456', author=user_2, image=image)
- Post.objects.create(text='Тестовый пост 9789', author=user_2, image=image)
- Post.objects.create(text='Тестовый пост 4574', author=user_2, image=image)
- > response = self.check_url(user_client, f'/follow', '/follow/')
- tests/test_follow.py:111:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- tests/test_follow.py:68: in check_url
- response = client.get(f'{url}/')
- venv/lib/python3.8/site-packages/django/test/client.py:535: in get
- response = super().get(path, data=data, secure=secure, **extra)
- venv/lib/python3.8/site-packages/django/test/client.py:345: in get
- return self.generic('GET', path, secure=secure, **{
- venv/lib/python3.8/site-packages/django/test/client.py:422: in generic
- return self.request(**r)
- venv/lib/python3.8/site-packages/django/test/client.py:503: in request
- raise exc_value
- venv/lib/python3.8/site-packages/django/core/handlers/exception.py:34: in inner
- response = get_response(request)
- venv/lib/python3.8/site-packages/django/core/handlers/base.py:115: in _get_response
- response = self.process_exception_by_middleware(e, request)
- venv/lib/python3.8/site-packages/django/core/handlers/base.py:113: in _get_response
- response = wrapped_callback(request, *callback_args, **callback_kwargs)
- venv/lib/python3.8/site-packages/django/contrib/auth/decorators.py:21: in _wrapped_view
- return view_func(request, *args, **kwargs)
- posts/views.py:206: in follow_index
- return render(
- venv/lib/python3.8/site-packages/django/shortcuts.py:36: in render
- content = loader.render_to_string(template_name, context, request, using=using)
- venv/lib/python3.8/site-packages/django/template/loader.py:61: in render_to_string
- template = get_template(template_name, using=using)
- venv/lib/python3.8/site-packages/django/template/loader.py:15: in get_template
- return engine.get_template(template_name)
- venv/lib/python3.8/site-packages/django/template/backends/django.py:34: in get_template
- return Template(self.engine.get_template(template_name), self)
- venv/lib/python3.8/site-packages/django/template/engine.py:143: in get_template
- template, origin = self.find_template(template_name)
- venv/lib/python3.8/site-packages/django/template/engine.py:125: in find_template
- template = loader.get_template(name, skip=skip)
- venv/lib/python3.8/site-packages/django/template/loaders/cached.py:54: in get_template
- template = super().get_template(template_name, skip)
- venv/lib/python3.8/site-packages/django/template/loaders/base.py:29: in get_template
- return Template(
- venv/lib/python3.8/site-packages/django/template/base.py:156: in __init__
- self.nodelist = self.compile_nodelist()
- venv/lib/python3.8/site-packages/django/template/base.py:194: in compile_nodelist
- return parser.parse()
- venv/lib/python3.8/site-packages/django/template/base.py:478: in parse
- raise self.error(token, e)
- venv/lib/python3.8/site-packages/django/template/base.py:476: in parse
- compiled_result = compile_func(self, token)
- venv/lib/python3.8/site-packages/django/template/loader_tags.py:266: in do_extends
- nodelist = parser.parse()
- venv/lib/python3.8/site-packages/django/template/base.py:478: in parse
- raise self.error(token, e)
- venv/lib/python3.8/site-packages/django/template/base.py:476: in parse
- compiled_result = compile_func(self, token)
- venv/lib/python3.8/site-packages/django/template/loader_tags.py:209: in do_block
- nodelist = parser.parse(('endblock',))
- venv/lib/python3.8/site-packages/django/template/base.py:483: in parse
- self.unclosed_block_tag(parse_until)
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <django.template.base.Parser object at 0x10b2957f0>, parse_until = ('endblock',)
- def unclosed_block_tag(self, parse_until):
- command, token = self.command_stack.pop()
- msg = "Unclosed tag on line %d: '%s'. Looking for one of: %s." % (
- token.lineno,
- command,
- ', '.join(parse_until),
- )
- > raise self.error(token, msg)
- E django.template.exceptions.TemplateSyntaxError: Unclosed tag on line 4: 'block'. Looking for one of: endblock.
- venv/lib/python3.8/site-packages/django/template/base.py:544: TemplateSyntaxError
- ------------------------------------------------------------------- Captured log call --------------------------------------------------------------------
- ERROR django.request:log.py:222 Internal Server Error: /follow/
- Traceback (most recent call last):
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
- response = get_response(request)
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 115, in _get_response
- response = self.process_exception_by_middleware(e, request)
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 113, in _get_response
- response = wrapped_callback(request, *callback_args, **callback_kwargs)
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
- return view_func(request, *args, **kwargs)
- File "/Users/matakov/Dev/hw05_final/posts/views.py", line 206, in follow_index
- return render(
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/shortcuts.py", line 36, in render
- content = loader.render_to_string(template_name, context, request, using=using)
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/template/loader.py", line 61, in render_to_string
- template = get_template(template_name, using=using)
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/template/loader.py", line 15, in get_template
- return engine.get_template(template_name)
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/template/backends/django.py", line 34, in get_template
- return Template(self.engine.get_template(template_name), self)
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/template/engine.py", line 143, in get_template
- template, origin = self.find_template(template_name)
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/template/engine.py", line 125, in find_template
- template = loader.get_template(name, skip=skip)
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/template/loaders/cached.py", line 54, in get_template
- template = super().get_template(template_name, skip)
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/template/loaders/base.py", line 29, in get_template
- return Template(
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/template/base.py", line 156, in __init__
- self.nodelist = self.compile_nodelist()
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/template/base.py", line 194, in compile_nodelist
- return parser.parse()
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/template/base.py", line 478, in parse
- raise self.error(token, e)
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/template/base.py", line 476, in parse
- compiled_result = compile_func(self, token)
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/template/loader_tags.py", line 266, in do_extends
- nodelist = parser.parse()
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/template/base.py", line 478, in parse
- raise self.error(token, e)
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/template/base.py", line 476, in parse
- compiled_result = compile_func(self, token)
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/template/loader_tags.py", line 209, in do_block
- nodelist = parser.parse(('endblock',))
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/template/base.py", line 483, in parse
- self.unclosed_block_tag(parse_until)
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/template/base.py", line 544, in unclosed_block_tag
- raise self.error(token, msg)
- django.template.exceptions.TemplateSyntaxError: Unclosed tag on line 4: 'block'. Looking for one of: endblock.
- _____________________________________________________________ TestGroupView.test_group_view ______________________________________________________________
- self = <tests.test_homework.TestGroupView object at 0x10b479580>, client = <django.test.client.Client object at 0x10b267730>
- post_with_group = <Post: Публикация от 2020-09-05 00:00 автора TestUser создана (Тестовый пост )>
- @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*'
- E AssertionError: Страница `/group/<slug>/` не найдена, проверьте этот адрес в *urls.py*
- E assert False
- tests/test_homework.py:170: AssertionError
- ------------------------------------------------------------------- Captured log call --------------------------------------------------------------------
- WARNING django.request:log.py:222 Not Found: /group/test-link/
- __________________________________________________ TestGroupPaginatorView.test_group_paginator_view_get __________________________________________________
- self = <tests.test_paginator.TestGroupPaginatorView object at 0x10b32e970>, client = <django.test.client.Client object at 0x10b519d90>
- post_with_group = <Post: Публикация от 2020-09-05 00:00 автора TestUser создана (Тестовый пост )>
- @pytest.mark.django_db(transaction=True)
- def test_group_paginator_view_get(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}/')
- > assert response.status_code != 404, 'Страница `/group/<slug>/` не найдена, проверьте этот адрес в *urls.py*'
- E AssertionError: Страница `/group/<slug>/` не найдена, проверьте этот адрес в *urls.py*
- E assert 404 != 404
- E + where 404 = <HttpResponse status_code=404, "text/html; charset=utf-8">.status_code
- tests/test_paginator.py:16: AssertionError
- ------------------------------------------------------------------- Captured log call --------------------------------------------------------------------
- WARNING django.request:log.py:222 Not Found: /group/test-link/
- __________________________________________________ TestGroupPaginatorView.test_index_paginator_view_get __________________________________________________
- self = <tests.test_paginator.TestGroupPaginatorView object at 0x10b52ad90>, client = <django.test.client.Client object at 0x10b523f40>
- post_with_group = <Post: Публикация от 2020-09-05 00:00 автора TestUser создана (Тестовый пост )>
- @pytest.mark.django_db(transaction=True)
- def test_index_paginator_view_get(self, client, post_with_group):
- response = client.get(f'/')
- > assert response.status_code != 404, 'Страница `/` не найдена, проверьте этот адрес в *urls.py*'
- E AssertionError: Страница `/` не найдена, проверьте этот адрес в *urls.py*
- E assert 404 != 404
- E + where 404 = <HttpResponse status_code=404, "text/html; charset=utf-8">.status_code
- tests/test_paginator.py:30: AssertionError
- ------------------------------------------------------------------- Captured log call --------------------------------------------------------------------
- WARNING django.request:log.py:222 Not Found: /
- _________________________________________________________ TestProfileView.test_profile_view_get __________________________________________________________
- self = <tests.test_profile.TestProfileView object at 0x10b531c70>, client = <django.test.client.Client object at 0x10b5b3910>
- post_with_group = <Post: Публикация от 2020-09-05 00:00 автора TestUser создана (Тестовый пост )>
- @pytest.mark.django_db(transaction=True)
- def test_profile_view_get(self, client, post_with_group):
- try:
- response = client.get(f'/{post_with_group.author.username}')
- except Exception as e:
- assert False, f'''Страница `/<username>/` работает неправильно. Ошибка: `{e}`'''
- if response.status_code in (301, 302):
- > response = client.get(f'/{post_with_group.author.username}/')
- tests/test_profile.py:23:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- venv/lib/python3.8/site-packages/django/test/client.py:535: in get
- response = super().get(path, data=data, secure=secure, **extra)
- venv/lib/python3.8/site-packages/django/test/client.py:345: in get
- return self.generic('GET', path, secure=secure, **{
- venv/lib/python3.8/site-packages/django/test/client.py:422: in generic
- return self.request(**r)
- venv/lib/python3.8/site-packages/django/test/client.py:503: in request
- raise exc_value
- venv/lib/python3.8/site-packages/django/core/handlers/exception.py:34: in inner
- response = get_response(request)
- venv/lib/python3.8/site-packages/django/core/handlers/base.py:115: in _get_response
- response = self.process_exception_by_middleware(e, request)
- venv/lib/python3.8/site-packages/django/core/handlers/base.py:113: in _get_response
- response = wrapped_callback(request, *callback_args, **callback_kwargs)
- posts/views.py:109: in profile
- if Follow.objects.filter(user=user, author=author):
- venv/lib/python3.8/site-packages/django/db/models/manager.py:82: in manager_method
- return getattr(self.get_queryset(), name)(*args, **kwargs)
- venv/lib/python3.8/site-packages/django/db/models/query.py:892: in filter
- return self._filter_or_exclude(False, *args, **kwargs)
- venv/lib/python3.8/site-packages/django/db/models/query.py:910: in _filter_or_exclude
- clone.query.add_q(Q(*args, **kwargs))
- venv/lib/python3.8/site-packages/django/db/models/sql/query.py:1290: in add_q
- clause, _ = self._add_q(q_object, self.used_aliases)
- venv/lib/python3.8/site-packages/django/db/models/sql/query.py:1315: in _add_q
- child_clause, needed_inner = self.build_filter(
- venv/lib/python3.8/site-packages/django/db/models/sql/query.py:1224: in build_filter
- self.check_related_objects(join_info.final_field, value, join_info.opts)
- venv/lib/python3.8/site-packages/django/db/models/sql/query.py:1086: in check_related_objects
- for v in value:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <SimpleLazyObject: <django.contrib.auth.models.AnonymousUser object at 0x10b55d700>>, args = ()
- def inner(self, *args):
- if self._wrapped is empty:
- self._setup()
- > return func(self._wrapped, *args)
- E TypeError: 'AnonymousUser' object is not iterable
- venv/lib/python3.8/site-packages/django/utils/functional.py:257: TypeError
- ------------------------------------------------------------------- Captured log call --------------------------------------------------------------------
- ERROR django.request:log.py:222 Internal Server Error: /TestUser/
- Traceback (most recent call last):
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
- response = get_response(request)
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 115, in _get_response
- response = self.process_exception_by_middleware(e, request)
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 113, in _get_response
- response = wrapped_callback(request, *callback_args, **callback_kwargs)
- File "/Users/matakov/Dev/hw05_final/posts/views.py", line 109, in profile
- if Follow.objects.filter(user=user, author=author):
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/db/models/manager.py", line 82, in manager_method
- return getattr(self.get_queryset(), name)(*args, **kwargs)
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/db/models/query.py", line 892, in filter
- return self._filter_or_exclude(False, *args, **kwargs)
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/db/models/query.py", line 910, in _filter_or_exclude
- clone.query.add_q(Q(*args, **kwargs))
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/db/models/sql/query.py", line 1290, in add_q
- clause, _ = self._add_q(q_object, self.used_aliases)
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/db/models/sql/query.py", line 1315, in _add_q
- child_clause, needed_inner = self.build_filter(
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/db/models/sql/query.py", line 1224, in build_filter
- self.check_related_objects(join_info.final_field, value, join_info.opts)
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/db/models/sql/query.py", line 1086, in check_related_objects
- for v in value:
- File "/Users/matakov/Dev/hw05_final/venv/lib/python3.8/site-packages/django/utils/functional.py", line 257, in inner
- return func(self._wrapped, *args)
- TypeError: 'AnonymousUser' object is not iterable
- ============================================================== 6 failed, 15 passed in 5.11s ==============================================================
- (venv) matakov@MBPD hw05_final %
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement