[py-svn] r37947 - in py/trunk/py/path/local: . testing

hpk at codespeak.net hpk at codespeak.net
Mon Feb 5 01:35:42 CET 2007


Author: hpk
Date: Mon Feb  5 01:35:40 2007
New Revision: 37947

Modified:
   py/trunk/py/path/local/local.py
   py/trunk/py/path/local/testing/test_local.py
Log:
added _gethomedir() helper to get at homedirectory


Modified: py/trunk/py/path/local/local.py
==============================================================================
--- py/trunk/py/path/local/local.py	(original)
+++ py/trunk/py/path/local/local.py	Mon Feb  5 01:35:40 2007
@@ -537,6 +537,15 @@
                         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
     #"""

Modified: py/trunk/py/path/local/testing/test_local.py
==============================================================================
--- py/trunk/py/path/local/testing/test_local.py	(original)
+++ py/trunk/py/path/local/testing/test_local.py	Mon Feb  5 01:35:40 2007
@@ -332,6 +332,10 @@
     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)



More information about the pytest-commit mailing list