Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyQuery object doesn't use the correct parser #245

Closed
spookylukey opened this issue Aug 24, 2022 · 0 comments
Closed

PyQuery object doesn't use the correct parser #245

spookylukey opened this issue Aug 24, 2022 · 0 comments

Comments

@spookylukey
Copy link
Contributor

The pyquery object that WebTest constructs does not specify the parser:

d = PyQuery(self.testbody)

Which means it uses the xml parser:

https://pyquery.readthedocs.io/en/latest/tips.html#using-different-parsers

For html responses, we should be using the html parser. For an example of the difference it makes, consider code inside a <script> tag:

>>> PyQuery('<html><body><script>var x = "<span></span>"; </script></body></html>').find('span')
[<span>]
>>> PyQuery('<html><body><script>var x = "<span></span>"; </script></body></html>', parser='html').find('span')
[]

The latter is what we want, and agrees with what browsers do.

@gawel gawel closed this as completed in 30d4a7b Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant