#36761: Closed file handles in test URL patterns for FileResponse
-------------------------------------+-------------------------------------
     Reporter:  Mohit Sharma         |                     Type:
                                     |  Cleanup/optimization
       Status:  new                  |                Component:  Testing
                                     |  framework
      Version:  dev                  |                 Severity:  Normal
     Keywords:  file-handle          |             Triage Stage:
  resource-cleanup testing           |  Unreviewed
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  1                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
 == Problem ==
 Test URL patterns in `tests/wsgi/urls.py` and `tests/asgi/urls.py` use
 lambda functions to open files for FileResponse without proper resource
 management.

 == Location ==
 - `tests/wsgi/urls.py:18`
 - `tests/asgi/urls.py:71`

 == Current Code ==
 path("file/", lambda x: FileResponse(open(__file__, "rb"))),== Solution ==
 Convert lambda functions to proper view functions to ensure better
 resource management and code clarity. FileResponse will still handle
 closing the file when the response is closed, but using proper view
 functions is cleaner and more maintainable.

 == Patch ==
 I have a patch ready that converts the lambda functions to proper view
 functions.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36761>
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 visit 
https://groups.google.com/d/msgid/django-updates/0107019adcb56595-2ce0e32b-933d-44a9-8946-b01bba7ce752-000000%40eu-central-1.amazonses.com.

Reply via email to