From ab050ba360c3f613065e365920a080445383d589 Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Mon, 30 Sep 2024 09:50:58 +0200 Subject: [PATCH] move tests into scopes package, provide runtests.sh calling zope-testrunner --- pyproject.toml | 9 +++++---- runtests.sh | 6 ++++-- scopes/tests/__init__.py | 1 + {tests => scopes/tests}/config.py | 0 {tests => scopes/tests}/test_postgres.py | 11 +++++++---- {tests => scopes/tests}/test_standard.py | 7 +++++-- {tests => scopes/tests}/tlib_server.py | 0 {tests => scopes/tests}/tlib_storage.py | 0 8 files changed, 22 insertions(+), 12 deletions(-) create mode 100644 scopes/tests/__init__.py rename {tests => scopes/tests}/config.py (100%) rename {tests => scopes/tests}/test_postgres.py (80%) rename {tests => scopes/tests}/test_standard.py (85%) rename {tests => scopes/tests}/tlib_server.py (100%) rename {tests => scopes/tests}/tlib_storage.py (100%) diff --git a/pyproject.toml b/pyproject.toml index 6c3e873..2b3ac1d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,13 +22,14 @@ postgres = [ "zope.sqlalchemy", ] app = ["python-dotenv", "zope.publisher", "zope.traversing"] -test = ["pytest"] +test = ["zope.testrunner"] +#test = ["pytest"] [tool.setuptools] packages = ["scopes"] -[tool.pytest.ini_options] -addopts = "-vv" -python_files = "test_standard.py" # default: run only `standard` tests +#[tool.pytest.ini_options] +#addopts = "-vv" +#python_files = "test_standard.py" # default: run only `standard` tests # use .pytest.ini file with `python_files = test_*.py` to run all tests diff --git a/runtests.sh b/runtests.sh index 53e3e91..6e514f2 100755 --- a/runtests.sh +++ b/runtests.sh @@ -1,3 +1,5 @@ +# runtests.sh +# run all unit / doc tests + +zope-testrunner --test-path=. $* -python tests/test_postgres.py $@ -python tests/test_standard.py $@ diff --git a/scopes/tests/__init__.py b/scopes/tests/__init__.py new file mode 100644 index 0000000..7076ddb --- /dev/null +++ b/scopes/tests/__init__.py @@ -0,0 +1 @@ +# py-scopes/tests diff --git a/tests/config.py b/scopes/tests/config.py similarity index 100% rename from tests/config.py rename to scopes/tests/config.py diff --git a/tests/test_postgres.py b/scopes/tests/test_postgres.py similarity index 80% rename from tests/test_postgres.py rename to scopes/tests/test_postgres.py index c4a61e8..f946931 100644 --- a/tests/test_postgres.py +++ b/scopes/tests/test_postgres.py @@ -1,9 +1,12 @@ -#! /usr/bin/python +# scopes.tests.test_postgres """Tests for the 'scopes.storage' package - using PostgreSQL.""" +import os, sys +sys.path = [os.path.dirname(__file__)] + sys.path + import unittest -import tlib_storage +from scopes.tests import tlib_storage from scopes.storage.db.postgres import StorageFactory import config @@ -29,10 +32,10 @@ class Test(unittest.TestCase): def test_004_topic(self): tlib_storage.test_topic(self, config) -def suite(): +def test_suite(): return unittest.TestSuite(( unittest.TestLoader().loadTestsFromTestCase(Test), )) if __name__ == '__main__': - unittest.main(defaultTest='suite') + unittest.main(defaultTest='test_suite') diff --git a/tests/test_standard.py b/scopes/tests/test_standard.py similarity index 85% rename from tests/test_standard.py rename to scopes/tests/test_standard.py index 0dcfcbb..d499b49 100644 --- a/tests/test_standard.py +++ b/scopes/tests/test_standard.py @@ -1,9 +1,12 @@ -#! /usr/bin/python +# scopes.tests.test_standard """Tests for the 'scopes.storage' package.""" +import os, sys +sys.path = [os.path.dirname(__file__)] + sys.path + import unittest -import tlib_server, tlib_storage +from scopes.tests import tlib_server, tlib_storage from scopes.storage.common import StorageFactory import config diff --git a/tests/tlib_server.py b/scopes/tests/tlib_server.py similarity index 100% rename from tests/tlib_server.py rename to scopes/tests/tlib_server.py diff --git a/tests/tlib_storage.py b/scopes/tests/tlib_storage.py similarity index 100% rename from tests/tlib_storage.py rename to scopes/tests/tlib_storage.py