[MERGE] * Fix the test HTTPServer to be isolated from chdir calls made while it is running
Robert Collins
robertc at robertcollins.net
Thu Feb 28 16:06:21 GMT 2008
On Wed, 2008-02-27 at 00:45 -0500, Aaron Bentley wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Robert Collins wrote:
> > Yay for ages spent scratching head. I can't believe this hasn't bitten
> > someone yet.
>
> bb:comment
>
> > + * 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.
Indeed.
> > 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
> urlutils.url_to_local_path.
>
> Please clarify that we're translating http URLs, not file URLs, and that
> the URL root location is the server's startup directory.
Will do. Note that the docstring I put in was copied *verbatim* from the
python standard library :).
>
> > + 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.)
As was all this code.
I'm not to worried about correctness here as it is working fine - the
less I touch it the happier I am.
-Rob
--
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20080229/e4f255a5/attachment.pgp
More information about the bazaar
mailing list