#34902: django.test.client.Client.head request fails on AttributeError as_sync 
is
missing
-----------------------------------------+------------------------
               Reporter:  jelly          |          Owner:  nobody
                   Type:  Uncategorized  |         Status:  new
              Component:  Uncategorized  |        Version:  4.2
               Severity:  Normal         |       Keywords:
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+------------------------
 A simple head request test now fails for me since Django 4.2. I do use
 pytest-django however I am not sure if this is related as the normal
 django test client is used.

 {{{
 def test_head(client):
     response = client.head('/packages/core/x86_64/linux/')
     assert response.status_code == 200
 }}}


 {{{
 client = <django.test.client.Client object at 0x7ffb428281d0>, package =
 None

     def test_head(client, package):
         print(client)
 >       response = client.head('/packages/core/x86_64/linux/')

 packages/tests/test_views.py:114:
 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
 env/lib/python3.11/site-packages/django/test/client.py:975: in head
     response = super().head(
 env/lib/python3.11/site-packages/django/test/client.py:495: in head
     return self.generic(
 env/lib/python3.11/site-packages/django/test/client.py:609: in generic
     return self.request(**r)
 env/lib/python3.11/site-packages/django/test/client.py:886: in request
     response = self.handler(environ)
 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

 self = <django.test.client.ClientHandler object at 0x7ffb427cae50>
 environ = {'HTTP_COOKIE': '', 'PATH_INFO': '/packages/core/x86_64/linux/',
 'QUERY_STRING': '', 'REMOTE_ADDR': '127.0.0.1', ...}

     def __call__(self, environ):
         # Set up middleware if needed. We couldn't do this earlier,
 because
         # settings weren't available.
         if self._middleware_chain is None:
             self.load_middleware()

         request_started.disconnect(close_old_connections)
         request_started.send(sender=self.__class__, environ=environ)
         request_started.connect(close_old_connections)
         request = WSGIRequest(environ)
         # sneaky little hack so that we can easily get round
         # CsrfViewMiddleware.  This makes life easier, and is probably
         # required for backwards compatibility with external tests against
         # admin views.
         request._dont_enforce_csrf_checks = not self.enforce_csrf_checks

         # Request goes through middleware.
         response = self.get_response(request)

         # Simulate behaviors of most web servers.
         conditional_content_removal(request, response)

         # Attach the originating request to the response so that it could
 be
         # later retrieved.
         response.wsgi_request = request

         # Emulate a WSGI server by calling the close method on completion.
         if response.streaming:
 >           if response.is_async:
 E           AttributeError: 'HttpResponse' object has no attribute
 'is_async'

 env/lib/python3.11/site-packages/django/test/client.py:187: AttributeError
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34902>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018b37c83f65-ca99de09-99d1-4d48-9bf3-fc50c9bced6c-000000%40eu-central-1.amazonses.com.

Reply via email to