Skip to content

Unit tests using APIClient request.DATA do not use a QueryDict. #3347

@ses4j

Description

@ses4j

I'm on Django 1.7 and DRF 2.4.x, don't know if that matters.

If I POST to an APIView, then inside the view the request.DATA is a QueryDict (and immutable), correctly. However, if I write a unit test and do APIClient().post(url, {}), the same request.DATA returns a regular dict. In the unit test case, it should normalize it as a QueryDict, so unit tests can catch bugs where the developer tries to mutate it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions