Easy of running .rst scenario files

29 views
Skip to first unread message

Dr. Praveen Bhatia

unread,
May 27, 2017, 5:10:42 AM5/27/17
to tryton
Hello,
   Is there an easy of running .rst scenario files in python that we can see in the source code:

Currently, I am copying this .rst file , renaming to .py file, commenting out non-commands and deleting >>> markers to convert to a normal python file. Can this file be run directly in python instead?
For example I do the following :

#================
#Invoice Scenario
#================

#Imports::
import datetime
from dateutil.relativedelta import relativedelta

from the original Few line of code from the top:


================
Invoice Scenario
================

Imports::
    >>> import datetime
    >>> from dateutil.relativedelta import relativedelta
    >>> from decimal import Decimal
    >>> from operator import attrgetter
    >>> from proteus import Model, Wizard
    >>> from trytond.tests.tools import activate_modules
    >>> from trytond.modules.company.tests.tools import create_company, \
    ...     get_company
    >>> from trytond.modules.account.tests.tools import create_fiscalyear, \
    ...     create_chart, get_accounts, create_tax, set_tax_code
    >>> from trytond.modules.account_invoice.tests.tools import \
    ...     set_fiscalyear_invoice_sequences
    >>> today = datetime.date.today()

Install account_invoice::

    >>> config = activate_modules('account_invoice')

Karla Stenger

unread,
May 27, 2017, 11:17:01 AM5/27/17
to try...@googlegroups.com
2017-05-27 6:10 GMT-03:00 Dr. Praveen Bhatia <praveen...@sumpurn.com>:
Hello,
   Is there an easy of running .rst scenario files in python that we can see in the source code:

​Hi,
Yes.
These files are part of the test suite of tryton, so to run them you need to run the test suite.
Here [1] is a nice explanation of several points that pokoli explained to me a while ago.

Hope this answers your question.
Cheers,
Karla.

--
-------------------------
Karla  Mª  Stenger  Sábat
karla....@gmail.com

Cédric Krier

unread,
May 28, 2017, 2:30:09 AM5/28/17
to try...@googlegroups.com
On 2017-05-27 12:16, Karla Stenger wrote:
> 2017-05-27 6:10 GMT-03:00 Dr. Praveen Bhatia <praveen...@sumpurn.com>:
>
> > Hello,
> > Is there an easy of running .rst scenario files in python that we can
> > see in the source code:
> > For ex: https://hg.tryton.org/modules/account_invoice/file/tip/
> > tests/scenario_invoice.rst#l37
> >
>
> ​Hi,
> Yes.
> These files are part of the test suite of tryton, so to run them you need
> to run the test suite.

Indeed it should be possible to run them outside the test suite by
using:

$ python -m doctest trytond/modules/account_invoice/tests/scenario_invoice.rst

But you have to define at least a database name with the environment
variable `DB_NAME` or `TRYTOND_DATABASE_URI`. You can also use the
`TRYTOND_CONFIG`.

--
Cédric Krier - B2CK SPRL
Email/Jabber: cedric...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/
Reply all
Reply to author
Forward
0 new messages