tests: support URL quoting on Python 3
We could use mercurial.urllibcompat, but meh. This makes things
easier to read.
The test still fails on Python 3 for some reason. But at least
we no longer have an exception.
Differential Revision: https://phab.mercurial-scm.org/D5669
tests: write directly to stdout to avoid b'' prefixes
This enables the test to pass on Python 3.
Differential Revision: https://phab.mercurial-scm.org/D5668