From 811fa68d1e332afbcbfbe0ff18a9e958f2e6c715 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 1 Jun 2015 22:52:59 +0200 Subject: [PATCH] Add test for README and docstring issue4779 review7181002 --- proteus/tests/__init__.py | 23 +++++++++++++++++++++++ proteus/tests/common.py | 3 --- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/proteus/tests/__init__.py b/proteus/tests/__init__.py index 2ea448e4f9..8f53f4b704 100644 --- a/proteus/tests/__init__.py +++ b/proteus/tests/__init__.py @@ -3,6 +3,17 @@ import os import sys import unittest +import doctest + +import proteus +import proteus.config + +os.environ.setdefault('TRYTOND_DATABASE_URI', 'sqlite://') +os.environ.setdefault('DB_NAME', ':memory:') +from trytond.tests.test_tryton import doctest_setup, doctest_teardown + +here = os.path.dirname(__file__) +readme = os.path.normpath(os.path.join(here, '..', '..', 'README')) def test_suite(): @@ -14,6 +25,18 @@ def test_suite(): __import__(modname) module = sys.modules[modname] suite.addTests(loader.loadTestsFromModule(module)) + additional_tests(suite) + return suite + + +def additional_tests(suite): + 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 diff --git a/proteus/tests/common.py b/proteus/tests/common.py index 81afcf7868..f075a20896 100644 --- a/proteus/tests/common.py +++ b/proteus/tests/common.py @@ -1,10 +1,7 @@ # 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 os from unittest import TestCase -os.environ.setdefault('TRYTOND_DATABASE_URI', 'sqlite://') -os.environ.setdefault('DB_NAME', ':memory:') from trytond.tests.test_tryton import db_exist, create_db from proteus import config