Skip to content

Loading…

TestApp.delete causes spurious warning #50

Closed
merwok opened this Issue · 8 comments

3 participants

@merwok

webtest/app.py:550: WSGIWarning: You are not supposed to send a body in a DELETE request. Most web servers will ignore it

This is caused by a test that checks if params is not NoDefault, but the default value is u'' instead of NoDefault.

(Side note: using the stacklevel param of warnings.warn will cause the traceback to show the line that called the function, not the line of the function that calls warn).

@domenkozar
Pylons Project member

Basically adding correct default to all methods would fix this. With a test case that warning is raised and adding stacklevel param to the warning.

@merwok

I could make a PR if you’re patient with my lack of git-fu.

@domenkozar
Pylons Project member

Sure, how can I help? :)

@merwok

I know how to clone, commit and push, but merging is still infuriatingly confusing to me, so if I use the wrong branch or get an unmergeable PR, I’ll need help :)

@domenkozar
Pylons Project member
@merwok

Yep, I know the basic flow as I said in my previous message, it’s really the branching model and the synchronization that don’t fit my head yet.

Basically adding correct default to all methods would fix this.

I did that and it does remove the spurious warning for DELETE.

With a test case that warning is raised and adding stacklevel param to the warning.

Problem is that warnings use their own reporting system, so you can’t just use assertRaises. In the stdlib we have special helpers to check that a warning was sent, but there’s nothing to do that in webtest at present.

stacklevel=3 does the right thing (3 = _gen_request → delete method → caller). I wanted to separate the two changes in two commits and then git hated me so I won’t push anything today, but I wanted to confirm the fixes.

@kmike

I think the correct way is to fix the warning issuing logic. Why is checking for if method == 'DELETE' and params: not enough? How is u'' non-empty?

@noonat noonat added a commit that referenced this issue
@noonat noonat Fix default value for delete params argument.
This fixes #50 in Pylons/webtest.
780560d
@noonat noonat added a commit that referenced this issue
@noonat noonat Fix default value for delete params argument.
This fixes #50 in Pylons/webtest.
f263aab
@domenkozar domenkozar closed this in #76
@merwok

Thanks for the fix @noonat ! The stacklevel value is still the old one, I may open another ticket for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.