Pylons / webtest

Wraps any WSGI application and makes it easy to send test requests to that application, without starting up an HTTP server.
https://docs.pylonsproject.org/projects/webtest/en/latest/
Other
336 stars 110 forks source link

"Your from_encoding will be ignored." warning #164

Closed karyon closed 7 years ago

karyon commented 8 years ago

i get this warning: /home/vagrant/django-webtest/.tox/py34-django110-std/lib/python3.4/site-packages/bs4/init.py:146: UserWarning: You provided Unicode markup but also provided a value for from_encoding. Your from_encoding will be ignored.``

i believe this is caused by https://github.com/Pylons/webtest/blob/9ca03a04927744fbea1b6a3fd209623981204bf1/webtest/forms.py#L404 (there may be other occurrences, haven't checked)

cheers :)

karyon commented 8 years ago

test output is a bit noisy right now, i'd like to see this fixed... if you tell me what the problem is and how to fix it, i can try and make a PR.

gawel commented 8 years ago

I guess you need to check if the data is unicode with python3 before using from_encoding

gawel commented 8 years ago

or maybe using self.body (which is str with python2 and bytes with python3) instead of self.text. Don't know what's the best option

digitalresistor commented 8 years ago

I would recommend using self.body.

karyon commented 8 years ago

@bertjwregeer why? just so i know why i'm doing what i'm doing if i'm doing such a PR :)

digitalresistor commented 8 years ago

I was confused, sorry, ignore my comment. self.text is separate from response.text. I thought it was a WebOb response object that was being used. response.text does magic based upon the response.charset.

gawel commented 8 years ago

I may have found a solution at #166 but I'm not really sure it will still fix #160

tdamsma commented 7 years ago

I also get this warning, is anyone working on fixing it? https://github.com/Pylons/webtest/pull/166 is open for months already

gawel commented 7 years ago

We were just waiting for your feedback. Can you confirm #166 fix the problem ?

tdamsma commented 7 years ago

I can confirm this fixes the warnings for me (python 3.5.2)

gawel commented 7 years ago

Ok thanks. Merged & released.