diff --git a/pubs/filebroker.py b/pubs/filebroker.py index 7043f4c..7c052b3 100644 --- a/pubs/filebroker.py +++ b/pubs/filebroker.py @@ -154,7 +154,7 @@ class DocBroker(object): def __init__(self, directory, scheme='docsdir', subdir='doc'): self.scheme = scheme - self.docdir = os.path.join(directory, subdir) + self.docdir = os.path.expanduser(os.path.join(directory, subdir)) if not check_directory(self.docdir, fail=False): os.mkdir(system_path(self.docdir)) diff --git a/tests/test_filebroker.py b/tests/test_filebroker.py index f8560a9..1f09008 100644 --- a/tests/test_filebroker.py +++ b/tests/test_filebroker.py @@ -71,6 +71,16 @@ class TestFileBroker(fake_env.TestFakeFs): class TestDocBroker(fake_env.TestFakeFs): + def test_expanduser(self): + """Test that real_docpath expand the user ~""" + + self.fs.add_real_directory(os.path.join(self.rootpath, 'data'), read_only=False) + fb = filebroker.FileBroker('~/testrepo', create = True) + docb = filebroker.DocBroker('~/testrepo') + self.assertTrue(os.path.isabs(docb.docdir)) + self.assertTrue(os.path.isabs(docb.real_docpath('docsdir://abc'))) + + def test_doccopy(self): self.fs.add_real_directory(os.path.join(self.rootpath, 'data'), read_only=False)