diff options
author | Steve Alexander <steve@z3u.com> | 2002-11-26 19:00:21 +0000 |
---|---|---|
committer | Steve Alexander <steve@z3u.com> | 2002-11-26 19:00:21 +0000 |
commit | 78790eb636e672cb694a9188dfced0b78534b8b3 (patch) | |
tree | 21ae5e9542bade5e4113b64a0faa2784168b1471 | |
parent | 4ca2d380d030bd23e687eed032770e75f0e6aca6 (diff) | |
download | zope-traversing-78790eb636e672cb694a9188dfced0b78534b8b3.tar.gz |
Fixed bug in getPhysicalPathString convenience function.
This function was not being unit tested at all!
That's not good.
-rw-r--r-- | __init__.py | 2 | ||||
-rw-r--r-- | tests/testConvenienceFunctions.py | 33 |
2 files changed, 28 insertions, 7 deletions
diff --git a/__init__.py b/__init__.py index b8e0ee5..530b43f 100644 --- a/__init__.py +++ b/__init__.py @@ -113,7 +113,7 @@ def getPhysicalPathString(obj): raise TypeError, "Not enough context information to traverse" path = _getAdapter(obj, _IPhysicallyLocatable).getPhysicalPath() - return '/'.join(path) + return locationAsUnicode(path) def getPhysicalRoot(obj): diff --git a/tests/testConvenienceFunctions.py b/tests/testConvenienceFunctions.py index ba9e11d..30520e8 100644 --- a/tests/testConvenienceFunctions.py +++ b/tests/testConvenienceFunctions.py @@ -13,7 +13,7 @@ ############################################################################## """ -$Id: testConvenienceFunctions.py,v 1.7 2002/11/26 13:14:50 stevea Exp $ +$Id: testConvenienceFunctions.py,v 1.8 2002/11/26 19:00:21 stevea Exp $ """ from unittest import TestCase, TestSuite, main, makeSuite from Zope.App.OFS.Services.ServiceManager.tests.PlacefulSetup \ @@ -49,7 +49,7 @@ class Test(PlacefulSetup, TestCase): folder = C('folder') item = C('item') - self.root = root + self.root = ContextWrapper(root, None) self.folder = ContextWrapper(folder, self.root, name='folder') self.item = ContextWrapper(item, self.folder, name='item') self.unwrapped_item = item @@ -119,7 +119,7 @@ class Test(PlacefulSetup, TestCase): self.assertEqual( objectName(self.item), 'item' - ) + ) def testObjectNameFromUnwrapped(self): from Zope.App.Traversing import objectName @@ -127,14 +127,14 @@ class Test(PlacefulSetup, TestCase): TypeError, objectName, self.unwrapped_item - ) + ) def testGetParent(self): from Zope.App.Traversing import getParent self.assertEqual( getParent(self.item), self.folder - ) + ) def testGetParentFromUnwrapped(self): from Zope.App.Traversing import getParent @@ -142,7 +142,7 @@ class Test(PlacefulSetup, TestCase): TypeError, getParent, self.unwrapped_item - ) + ) def testGetParents(self): from Zope.App.Traversing import getParents @@ -166,6 +166,27 @@ class Test(PlacefulSetup, TestCase): ('', 'folder', 'item') ) + def testGetPhysicalPathString(self): + from Zope.App.Traversing import getPhysicalPathString + self.assertEqual( + getPhysicalPathString(self.item), + u'/folder/item' + ) + + def testGetPhysicalPathOfRoot(self): + from Zope.App.Traversing import getPhysicalPath + self.assertEqual( + getPhysicalPath(self.root), + ('',) + ) + + def testGetPhysicalPathStringOfRoot(self): + from Zope.App.Traversing import getPhysicalPathString + self.assertEqual( + getPhysicalPathString(self.root), + u'/', + ) + def testGetPhysicalPathFromUnwrapped(self): from Zope.App.Traversing import getPhysicalPath self.assertRaises( |