changeset 769aaf925bfa in proteus:default
details: https://hg.tryton.org/proteus?cmd=changeset&node=769aaf925bfa
description:
Replace test setuptools command by unittest discover
issue9215
review389851002
diffstat:
CHANGELOG | 1 +
proteus/tests/__init__.py | 45 --------------------------------------------
proteus/tests/test_readme.py | 22 +++++++++++++++++++++
setup.py | 7 +++--
tox.ini | 3 +-
5 files changed, 29 insertions(+), 49 deletions(-)
diffs (124 lines):
diff -r 6c577f11df78 -r 769aaf925bfa CHANGELOG
--- a/CHANGELOG Mon Apr 11 23:41:21 2022 +0200
+++ b/CHANGELOG Sat Apr 16 18:30:20 2022 +0200
@@ -1,3 +1,4 @@
+* Use unittest discover
* Support notification message
* Use defusedxml to parse XML (11244)
* Add support for Python 3.10
diff -r 6c577f11df78 -r 769aaf925bfa proteus/tests/__init__.py
--- a/proteus/tests/__init__.py Mon Apr 11 23:41:21 2022 +0200
+++ b/proteus/tests/__init__.py Sat Apr 16 18:30:20 2022 +0200
@@ -1,54 +1,9 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
-import doctest
import os
-import sys
-import unittest
-
-import proteus
-import proteus.config
os.environ.setdefault('TRYTOND_DATABASE_URI', 'sqlite:///')
os.environ.setdefault('DB_NAME', ':memory:')
-from trytond.tests.test_tryton import ( # noqa: E402
- doctest_setup, doctest_teardown)
here = os.path.dirname(__file__)
readme = os.path.normpath(os.path.join(here, '..', '..', 'README.rst'))
-
-
-def test_suite():
- suite = unittest.TestSuite()
- loader = unittest.TestLoader()
- for filename in os.listdir(os.path.dirname(__file__)):
- if filename.startswith("test") and filename.endswith(".py"):
- modname = "proteus.tests." + filename[:-3]
- __import__(modname)
- module = sys.modules[modname]
- suite.addTests(loader.loadTestsFromModule(module))
- suite.addTests(additional_tests())
- return suite
-
-
-def additional_tests():
- suite = unittest.TestSuite()
- for mod in (proteus, proteus.config):
- suite.addTest(doctest.DocTestSuite(mod))
- if os.path.isfile(readme):
- suite.addTest(doctest.DocFileSuite(readme, module_relative=False,
- setUp=doctest_setup, tearDown=doctest_teardown,
- encoding='utf-8',
- optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
- return suite
-
-
-def main():
- suite = test_suite()
- runner = unittest.TextTestRunner()
- return runner.run(suite)
-
-
-if __name__ == '__main__':
- sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
- sys.exit(not main().wasSuccessful())
diff -r 6c577f11df78 -r 769aaf925bfa proteus/tests/test_readme.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/proteus/tests/test_readme.py Sat Apr 16 18:30:20 2022 +0200
@@ -0,0 +1,22 @@
+# This file is part of Tryton. The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
+import doctest
+import os
+
+import proteus
+import proteus.config
+from trytond.tests.test_tryton import doctest_setup, doctest_teardown
+
+here = os.path.dirname(__file__)
+readme = os.path.normpath(os.path.join(here, '..', '..', 'README.rst'))
+
+
+def load_tests(loader, tests, pattern):
+ for mod in (proteus, proteus.config):
+ tests.addTest(doctest.DocTestSuite(mod))
+ if os.path.isfile(readme):
+ tests.addTest(doctest.DocFileSuite(
+ readme, module_relative=False,
+ setUp=doctest_setup, tearDown=doctest_teardown,
+ encoding='utf-8',
+ optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
diff -r 6c577f11df78 -r 769aaf925bfa setup.py
--- a/setup.py Mon Apr 11 23:41:21 2022 +0200
+++ b/setup.py Sat Apr 16 18:30:20 2022 +0200
@@ -103,10 +103,11 @@
],
extras_require={
'trytond': [get_require_version('trytond')],
+ 'test': [
+ get_require_version('trytond'),
+ get_require_version('trytond_party'),
+ ],
},
dependency_links=dependency_links,
zip_safe=True,
- test_suite='proteus.tests',
- tests_require=[get_require_version('trytond'),
- get_require_version('trytond_party')],
)
diff -r 6c577f11df78 -r 769aaf925bfa tox.ini
--- a/tox.ini Mon Apr 11 23:41:21 2022 +0200
+++ b/tox.ini Sat Apr 16 18:30:20 2022 +0200
@@ -2,8 +2,9 @@
envlist = py37,py38,py39,py310
[testenv]
+extras = test
commands =
- coverage run setup.py test
+ coverage run -m unittest discover -s proteus.tests
coverage report --include=./proteus/* --omit=*/tests/*
deps = coverage
setenv =