diff --git a/py/path/local/local.py b/py/path/local/local.py index f461f4c1f..a1c03d9fb 100644 --- a/py/path/local/local.py +++ b/py/path/local/local.py @@ -537,6 +537,15 @@ class LocalPath(common.FSPathBase, PlatformMixin): pass return None sysfind = classmethod(sysfind) + + def _gethomedir(cls): + try: + x = os.environ['HOME'] + except KeyError: + x = os.environ['HOMEPATH'] + return cls(x) + _gethomedir = classmethod(_gethomedir) + #""" #special class constructors for local filesystem paths #""" diff --git a/py/path/local/testing/test_local.py b/py/path/local/testing/test_local.py index 7e1cbb387..469cb14d4 100644 --- a/py/path/local/testing/test_local.py +++ b/py/path/local/testing/test_local.py @@ -332,6 +332,10 @@ def test_pypkgdir(): assert pkg.pypkgpath() == pkg assert pkg.join('subdir', '__init__.py').pypkgpath() == pkg +def test_homedir(): + homedir = py.path.local._gethomedir() + assert homedir.check(dir=1) + #class XTestLocalPath(TestLocalPath): # def __init__(self): # TestLocalPath.__init__(self)