Merge lp://staging/~gz/launchpadlib/trivial_homeless_launchpadlib_dir into lp://staging/launchpadlib

Proposed by Martin Packman
Status: Merged
Approved by: Robert Collins
Approved revision: 109
Merged at revision: 120
Proposed branch: lp://staging/~gz/launchpadlib/trivial_homeless_launchpadlib_dir
Merge into: lp://staging/launchpadlib
Diff against target: 17 lines (+4/-2)
1 file modified
src/launchpadlib/launchpad.py (+4/-2)
To merge this branch: bzr merge lp://staging/~gz/launchpadlib/trivial_homeless_launchpadlib_dir
Reviewer Review Type Date Requested Status
Robert Collins (community) Approve
Graham Binns (community) code Needs Fixing
Review via email: mp+46150@code.staging.launchpad.net

Commit message

Improve Launchpadlib for windows.

Description of the change

Two changes to launchpadlib_dir behaviour when HOME is not set. Firstly, it may be HOMEDRIVE and HOMEPATH on windows, which os.path.expanduser already has logic for checking, so just use that. Secondly, if expanduser fails (returning the original string starting with a tilde still), raise a useful error giving a hint to either fix the environment or pass a usable value for launchpadlib_dir.

I'd like to poke some of the tests along with this, but they're not syntax compatible with my installed python version and the pain of setuptools and many dependencies is too great for my trunk build. In particular test_launchpad.test_None_launchpadlib_dir could do with fixing.

To post a comment you must log in.
Revision history for this message
Leonard Richardson (leonardr) wrote :

I need to add some tests and then I'll land this, probably next week.

Revision history for this message
Graham Binns (gmb) wrote :

For the sake of making this disappear from the +activereviews queue I'm adding a Needs Fixing as a proxy for Leonard (above) and marking it Work in Progress until there are some tests for the change.

review: Needs Fixing (code)
Revision history for this message
Graham Binns (gmb) wrote :

(And by disappear I don't mean that we don't want to see this branch; if it's work in progress (which it is) it shouldn't be in the list of branches that I need to review).

Revision history for this message
Martin Packman (gz) wrote :

Leonard no longer works for Canonical.

I've confirmed the exiting tests pass with this branch merged (it would be nice if they were easier to run), and that the change fixes the bug reported. Given the state of the launchpadlib test suite, I don't see the point of blocking a trivial change like this indefinitely. It would be possible to add a unit test that confirms this specific behaviour change functions correctly, but by design it depends posixpath.expanduser and ntpath.expanduser behaviour. The former uses getuid and the pwd module to get the correct directory when HOME doesn't exist, which make setting up a sensible test environment onerous. I could fake out the os module to test the ValueError is raised correctly, but really Python's coverage of the os.path module should be sufficient.

Revision history for this message
Robert Collins (lifeless) wrote :

So to land it we just need to make sure the tests will still pass on (probably natty). If they do, +1. If not, then I hope that the reviewer will pick this up and fix it.

review: Approve
Revision history for this message
Robert Collins (lifeless) wrote :

if launchpadlib_dir[:1] == '~':
would be clearer as
if launchpadlib_dir.startswith('~'):

Revision history for this message
Martin Packman (gz) wrote :

Thanks Robert!

...I don't remember why I used a slice and not startswith.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches