diff --git a/setup.py b/setup.py index 94c5baefbf..026e54ff20 100644 --- a/setup.py +++ b/setup.py @@ -53,6 +53,7 @@ for dep in info.get('depends', []): requires.append(get_require_version('trytond_%s' % dep)) requires.append(get_require_version('trytond')) +tests_require = [get_require_version('proteus')] dependency_links = [] if minor_version % 2: dependency_links.append('https://trydevpi.tryton.org/') @@ -119,5 +120,9 @@ setup(name=name, """, test_suite='tests', test_loader='trytond.test_loader:Loader', + tests_require=tests_require, use_2to3=True, + convert_2to3_doctests=[ + 'tests/scenario_currency_compute.rst', + ], ) diff --git a/tests/scenario_currency_compute.rst b/tests/scenario_currency_compute.rst new file mode 100644 index 0000000000..bf494f95a5 --- /dev/null +++ b/tests/scenario_currency_compute.rst @@ -0,0 +1,22 @@ +========================= +Currency Compute Scenario +========================= + +Imports:: + + >>> from decimal import Decimal + >>> from proteus import Model + >>> from trytond.tests.tools import activate_modules + >>> from trytond.modules.currency.tests.tools import get_currency + +Install currency:: + + >>> config = activate_modules('currency') + +Call compute:: + + >>> Currency = Model.get('currency.currency') + >>> usd = get_currency(code='USD') + >>> eur = get_currency(code='EUR') + >>> Currency.compute(usd.id, Decimal('10.00'), eur.id, {}) + Decimal('20.00') diff --git a/tests/test_currency.py b/tests/test_currency.py index a880970cee..7000011a02 100644 --- a/tests/test_currency.py +++ b/tests/test_currency.py @@ -1,11 +1,14 @@ # 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 datetime +import doctest import unittest from decimal import Decimal import trytond.tests.test_tryton from trytond.transaction import Transaction from trytond.tests.test_tryton import ModuleTestCase, with_transaction +from trytond.tests.test_tryton import doctest_teardown +from trytond.tests.test_tryton import doctest_checker from trytond.pool import Pool @@ -257,4 +260,9 @@ def suite(): suite = trytond.tests.test_tryton.suite() suite.addTests(unittest.TestLoader().loadTestsFromTestCase( CurrencyTestCase)) + suite.addTests(doctest.DocFileSuite( + 'scenario_currency_compute.rst', + tearDown=doctest_teardown, encoding='utf-8', + checker=doctest_checker, + optionflags=doctest.REPORT_ONLY_FIRST_FAILURE)) return suite