[MERGE] * Fix the test HTTPServer to be isolated from chdir calls made while it is running
aaron at aaronbentley.com
Wed Feb 27 05:45:28 GMT 2008
-----BEGIN PGP SIGNED MESSAGE-----
Robert Collins wrote:
> Yay for ages spent scratching head. I can't believe this hasn't bitten
> someone yet.
> + * Fix the test HTTPServer to be isolated from chdir calls made while it is
> + running, allowing it to be used in blackbox tests. (Robert Collins)
Good grief! This should never have been necessary.
> def _translate_path(self, path):
> - return SimpleHTTPServer.SimpleHTTPRequestHandler.translate_path(
> - self, path)
> + """Translate a /-separated PATH to the local filename syntax.
At first glance, I wondered why you weren't using
Please clarify that we're translating http URLs, not file URLs, and that
the URL root location is the server's startup directory.
> + for word in words:
> + drive, word = os.path.splitdrive(word)
> + head, word = os.path.split(word)
> + if word in (os.curdir, os.pardir): continue
> + path = os.path.join(path, word)
> + return path
This looks odd. Is it really the right thing to look for a drive in
every component of the URL? Why are we splitting off head everywhere?
(I'm guessing this is all copy-paste code, but it still looks kinda wrong.)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
More information about the bazaar