diff --git a/CHANGES.rst b/CHANGES.rst index 65e18416ac..f8cb98df98 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -40,6 +40,9 @@ New features: Bug fixes: +- Fixed getObjSize indexer for Python 3. #2526 + [reinhardt] + - Remove the devdependencies from bower.json - they are just used for running tests in mockup, not here. [sunew] diff --git a/Products/CMFPlone/CatalogTool.py b/Products/CMFPlone/CatalogTool.py index 6ca37339b1..c972acf0cd 100644 --- a/Products/CMFPlone/CatalogTool.py +++ b/Products/CMFPlone/CatalogTool.py @@ -244,7 +244,7 @@ def getObjSize(obj): if size < SIZE_CONST[smaller]: return '1 %s' % smaller for c in SIZE_ORDER: - if size / SIZE_CONST[c] > 0: + if size // SIZE_CONST[c] > 0: break return '%.1f %s' % (float(size / float(SIZE_CONST[c])), c) return size diff --git a/Products/CMFPlone/tests/testCatalogTool.py b/Products/CMFPlone/tests/testCatalogTool.py index a5eec9d5f3..5f491ef7e9 100644 --- a/Products/CMFPlone/tests/testCatalogTool.py +++ b/Products/CMFPlone/tests/testCatalogTool.py @@ -1303,14 +1303,20 @@ def test_provided(self): self.assertTrue(IIndexableObjectWrapper.providedBy(w)) self.assertTrue(IContentish.providedBy(w)) - def test_getObjSize(self): + def test_getObjSize_KB(self): from Products.CMFPlone.CatalogTool import getObjSize get_size = getObjSize.callable - # FIXME: getObjSize die not count text in DX self.doc.text = RichTextValue('a' * 1000) self.doc.reindexObject() self.assertEqual(get_size(self.doc), '1 KB') + def test_getObjSize_MB(self): + from Products.CMFPlone.CatalogTool import getObjSize + get_size = getObjSize.callable + self.doc.text = RichTextValue('a' * 6000000) + self.doc.reindexObject() + self.assertEqual(get_size(self.doc), '5.7 MB') + def test_uuid(self): alsoProvides(self.doc, IAttributeUUID) notify(ObjectCreatedEvent(self.doc))