From f2a737e0a80853cded8218e18daf357ebc531b4d Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Sat, 28 Sep 2024 09:03:56 +0200 Subject: [PATCH] storage: tests with Python3 OK --- loops/classifier/testsetup.py | 7 +++---- loops/storage/tests/test_storage.py | 16 +++++++++++++--- loops/tests/__init__.py | 11 ++++++++--- loops/util.py | 2 +- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/loops/classifier/testsetup.py b/loops/classifier/testsetup.py index b3414e7..da572dc 100644 --- a/loops/classifier/testsetup.py +++ b/loops/classifier/testsetup.py @@ -1,13 +1,12 @@ +# loops.classifier.testsetup """ Set up a loops site for testing. - -$Id$ """ import os from zope import component -#from zope.app.catalog.interfaces import ICatalog -#from zope.app.catalog.text import TextIndex +#from zope.catalog.interfaces import ICatalog +#from zope.catalog.text import TextIndex from cybertools.storage.interfaces import IExternalStorage from cybertools.storage.filesystem import fullPathStorage diff --git a/loops/storage/tests/test_storage.py b/loops/storage/tests/test_storage.py index 3e4f0c7..1ab64af 100644 --- a/loops/storage/tests/test_storage.py +++ b/loops/storage/tests/test_storage.py @@ -3,9 +3,13 @@ """Comprehensive functional testing for SQL-based storage implementation. """ +from loops.tests import fixPythonPath +fixPythonPath() + from loops.storage.tests import common import transaction +import unittest from zope import component from zope.traversing.api import getName @@ -24,7 +28,7 @@ class TestStorage(common.TestCase): def test_000_setUp(self): self.prepare() self.assertEqual(str(self.g.storage.engine.url), - 'postgresql://ccotest:cco@localhost:5432/ccotest') + 'postgresql+psycopg://ccotest:***@localhost:5432/ccotest') self.g.storage.dropTable('favorites') self.g.storage.dropTable('uid_mapping') component.provideAdapter(FavoritesAdapter) @@ -71,6 +75,12 @@ class TestStorage(common.TestCase): self.cleanup() -if __name__ == '__main__': - unittest.main() +def test_suite(): + return unittest.TestSuite(( + unittest.makeSuite(TestStorage), + )) + + +if __name__ == '__main__': + unittest.main(defaultTest='test_suite') diff --git a/loops/tests/__init__.py b/loops/tests/__init__.py index 4bc90fb..4d2a56d 100644 --- a/loops/tests/__init__.py +++ b/loops/tests/__init__.py @@ -1,4 +1,9 @@ -""" -$Id$ -""" +# loops.tests +import os.path +import sys + +def fixPythonPath(doPrint=False): + sys.path = [os.path.dirname(__file__)] + sys.path[1:] + if doPrint: + print('sys.path =', sys.path) diff --git a/loops/util.py b/loops/util.py index b6fe268..c646681 100644 --- a/loops/util.py +++ b/loops/util.py @@ -26,7 +26,7 @@ import cybertools from cybertools.meta.interfaces import IOptions from loops.browser.util import html_quote -try: # for testing! +try: # avoid error when testing import config from loops.storage.compat.common import StorageFactory storageFactory = StorageFactory(config)