[Django] #30677: Improve Exception Message In Test Client when a None Value is provided to a POST

18 views
Skip to first unread message

Django

unread,
Aug 4, 2019, 8:51:03 PM8/4/19
to django-...@googlegroups.com
#30677: Improve Exception Message In Test Client when a None Value is provided to a
POST
-------------------------------------+-------------------------------------
Reporter: idahogray | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Testing | Version: 2.2
framework |
Severity: Normal | Keywords: test client post
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
I am upgrading to 2.2.1 from 2.0.5 and my tests are failing due to a
change in the test client:
https://docs.djangoproject.com/en/2.2/releases/2.2/#miscellaneous. It now
throws an exception if a None value is provided in data given to a POST. I
would like to propose an improvement to the message to display the
offending Key and Value that generate the exception.

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

Django

unread,
Aug 4, 2019, 8:58:22 PM8/4/19
to django-...@googlegroups.com
#30677: Improve Exception Message In Test Client when a None Value is provided to a
POST
-------------------------------------+-------------------------------------
Reporter: idahogray | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Testing framework | Version: 2.2
Severity: Normal | Resolution:

Keywords: test client post | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by idahogray):

* has_patch: 0 => 1


Old description:

> I am upgrading to 2.2.1 from 2.0.5 and my tests are failing due to a
> change in the test client:
> https://docs.djangoproject.com/en/2.2/releases/2.2/#miscellaneous. It now
> throws an exception if a None value is provided in data given to a POST.
> I would like to propose an improvement to the message to display the
> offending Key and Value that generate the exception.

New description:

I am upgrading to 2.2.1 from 2.0.5 and my tests are failing due to a
change in the test client:
https://docs.djangoproject.com/en/2.2/releases/2.2/#miscellaneous. It now
throws an exception if a None value is provided in data given to a POST. I
would like to propose an improvement to the message to display the
offending Key and Value that generate the exception.

I have a proposed change in my fork on github:
https://github.com/idahogray/django/tree/ticket_30677

--

--
Ticket URL: <https://code.djangoproject.com/ticket/30677#comment:1>

Django

unread,
Aug 4, 2019, 11:37:16 PM8/4/19
to django-...@googlegroups.com
#30677: Improve Exception Message In Test Client when a None Value is provided to a
POST
--------------------------------------+------------------------------------
Reporter: Keith Gray | Owner: nobody
Type: Cleanup/optimization | Status: new

Component: Testing framework | Version: 2.2
Severity: Normal | Resolution:
Keywords: test client post | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Markus Holtermann):

* stage: Unreviewed => Accepted


Comment:

I like your suggestion. I would suggest a slightly different wording:
{{{#!python
raise TypeError(
"Cannot encode None for key '%s' as POST data. Did you
mean "
"to pass an empty string or omit the value?" % key
)
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30677#comment:2>

Django

unread,
Aug 5, 2019, 1:10:01 AM8/5/19
to django-...@googlegroups.com
#30677: Improve Exception Message In Test Client when a None Value is provided to a
POST.

--------------------------------------+------------------------------------
Reporter: Keith Gray | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: test client post | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by felixxm):

* has_patch: 1 => 0
* version: 2.2 => master


Comment:

I agree with Markus' suggestion. Can you create PR via GitHub?

--
Ticket URL: <https://code.djangoproject.com/ticket/30677#comment:3>

Django

unread,
Aug 5, 2019, 9:53:32 AM8/5/19
to django-...@googlegroups.com
#30677: Improve Exception Message In Test Client when a None Value is provided to a
POST.
--------------------------------------+------------------------------------
Reporter: Keith Gray | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: test client post | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by Keith Gray):

I will change the wording and create a PR. I have one more question, can I
use f-strings since this is going into master? I cloned the repo and tried
to run the tests in a Python 3.5 environment but it wouldn't let me.

--
Ticket URL: <https://code.djangoproject.com/ticket/30677#comment:4>

Django

unread,
Aug 5, 2019, 9:59:25 AM8/5/19
to django-...@googlegroups.com
#30677: Improve Exception Message In Test Client when a None Value is provided to a
POST.
--------------------------------------+------------------------------------
Reporter: Keith Gray | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: test client post | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by felixxm):

Django 3.0 supports Python 3.6+, nevertheless please don't use f-strings
(see #29988).

--
Ticket URL: <https://code.djangoproject.com/ticket/30677#comment:5>

Django

unread,
Aug 8, 2019, 3:28:39 PM8/8/19
to django-...@googlegroups.com
#30677: Improve Exception Message In Test Client when a None Value is provided to a
POST.
--------------------------------------+------------------------------------
Reporter: Keith Gray | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: test client post | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by felixxm):

* easy: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/30677#comment:6>

Django

unread,
Aug 9, 2019, 2:21:31 AM8/9/19
to django-...@googlegroups.com
#30677: Improve Exception Message In Test Client when a None Value is provided to a
POST.
-------------------------------------+-------------------------------------
Reporter: Keith Gray | Owner: Swatantra
Type: | Status: assigned
Cleanup/optimization |

Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: test client post | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Swatantra):

* status: new => assigned
* owner: nobody => Swatantra


--
Ticket URL: <https://code.djangoproject.com/ticket/30677#comment:7>

Django

unread,
Aug 11, 2019, 9:52:17 AM8/11/19
to django-...@googlegroups.com
#30677: Improve Exception Message In Test Client when a None Value is provided to a
POST.
-------------------------------------+-------------------------------------
Reporter: Keith Gray | Owner: Swatantra
Type: | Status: assigned
Cleanup/optimization |
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: test client post | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* needs_better_patch: 0 => 1


* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/11638 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/30677#comment:8>

Django

unread,
Aug 11, 2019, 2:11:43 PM8/11/19
to django-...@googlegroups.com
#30677: Improve Exception Message In Test Client and urlencode() when None is
passed as data.

-------------------------------------+-------------------------------------
Reporter: Keith Gray | Owner: Swatantra
Type: | Status: assigned
Cleanup/optimization |
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: test client post | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/30677#comment:9>

Django

unread,
Aug 11, 2019, 2:23:33 PM8/11/19
to django-...@googlegroups.com
#30677: Improve Exception Message In Test Client and urlencode() when None is
passed as data.
-------------------------------------+-------------------------------------
Reporter: Keith Gray | Owner: Swatantra
Type: | Status: assigned
Cleanup/optimization |
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: test client post | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Keith Gray):

Sorry for the delayed response, i was traveling this week. Thanks for
picking this up.

--
Ticket URL: <https://code.djangoproject.com/ticket/30677#comment:10>

Django

unread,
Aug 11, 2019, 3:50:56 PM8/11/19
to django-...@googlegroups.com
#30677: Improve Exception Message In Test Client and urlencode() when None is
passed as data.
-------------------------------------+-------------------------------------
Reporter: Keith Gray | Owner: Swatantra
Type: | Status: closed

Cleanup/optimization |
Component: Testing framework | Version: master
Severity: Normal | Resolution: fixed

Keywords: test client post | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"73ac9e3f04c4a1a6b1add05c207d11c8ff461b7d" 73ac9e3]:
{{{
#!CommitTicketReference repository=""
revision="73ac9e3f04c4a1a6b1add05c207d11c8ff461b7d"
Fixed #30677 -- Improved error message for urlencode() and Client when


None is passed as data.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30677#comment:11>

Reply all
Reply to author
Forward
0 new messages