How to run unittest

34 views
Skip to first unread message

Markus Bala

unread,
Oct 17, 2016, 9:32:48 AM10/17/16
to tryton-dev
Hi All,

Seeing the official modules have Test folder, it contains test case and scenario.
May I know how to run test case?
or when can I find the documentation for unittest?
1. What are prerequisite?
2. How to write?
3. How to run?

best regard,
Markus Bala

Sergi Almacellas Abellana

unread,
Oct 17, 2016, 9:45:16 AM10/17/16
to tryto...@googlegroups.com
El 17/10/16 a les 15:32, Markus Bala ha escrit:
> Hi All,
>
> Seeing the official modules have Test folder, it contains test case and
> scenario.
> May I know how to run test case?

You have several possibilities here:

1. Run the run-test.py[1] script from the tryton server using the -m
<module_name> to execu
2. Execute python setup.py test with the DB_NAME key set in the
environemnt. For example, for runing in a memory sqlite database you can
use the following command:

DB_NAME=:memory: python setup.py test

Note: The second will install the package and the required dependencies.
> or when can I find the documentation for unittest?
> 1. What are prerequisite?
> 2. How to write?
> 3. How to run?

I've done some talk about it in the past, you have the slides avaialble
here [2] and the video record [3] (sorry but only in spanish)

Hope it helps!

[1]
http://hg.tryton.org/trytond/file/9c2eb1b04df8/trytond/tests/run-tests.py
[2] http://pokoli.github.io/testing-in-tryton/#/
[3] https://www.youtube.com/watch?v=cGfz3MaNxec
--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk

Markus Bala

unread,
Oct 17, 2016, 1:27:50 PM10/17/16
to Tryton
 Hi Sergi,

thank you for your comment. 
Now I understand where to start to write my unit test. I will try later.

I have a question. 
Is it possible Proteus able to call method/function?

best regard

--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk


--
You received this message because you are subscribed to the Google Groups "tryton-dev" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/tryton-dev/88795a5f-73ba-63fa-2716-2b6dd762e968%40koolpi.com.

Sergi Almacellas Abellana

unread,
Oct 18, 2016, 4:18:38 AM10/18/16
to tryto...@googlegroups.com
El 17/10/16 a les 19:27, Markus Bala ha escrit:
> thank you for your comment.
> Now I understand where to start to write my unit test. I will try later.
>
> I have a question.
> Is it possible Proteus able to call method/function?
Yes, you can use proteus to call any RPC method, but I'm pretty sure we
can give a better advice if you explain more concretly what do you want
to do we can give a better advice.

Also, make sure to take a look at the standard module test to have an
idea of what it's possible to do and come here with your doubts if any.

Hope it helps!

Markus Bala

unread,
Oct 18, 2016, 4:28:11 AM10/18/16
to Tryton
On Tue, Oct 18, 2016 at 3:18 PM, Sergi Almacellas Abellana <se...@koolpi.com> wrote:
El 17/10/16 a les 19:27, Markus Bala ha escrit:
thank you for your comment.
Now I understand where to start to write my unit test. I will try later.

I have a question.
Is it possible Proteus able to call method/function?
Yes, you can use proteus to call any RPC method, but I'm pretty sure we can give a better advice if you explain more concretly what do you want to do we can give a better advice.

Also, make sure to take a look at the standard module test to have an idea of what it's possible to do and come here with your doubts if any.

Hope it helps!

Hi Sergi,

Example code as below, if in the proteus, how am I going to call "test_method"?

Class stock_move:
    def test_method(self, value1, value2):
        return value1 + value2
 


--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk

--
You received this message because you are subscribed to the Google Groups "tryton-dev" group.

Sergi Almacellas Abellana

unread,
Oct 18, 2016, 4:44:35 AM10/18/16
to tryto...@googlegroups.com
El 18/10/16 a les 10:27, Markus Bala ha escrit:
> Hi Sergi,
>
> Example code as below, if in the proteus, how am I going to call
> "test_method"?
>
> Class stock_move:
> def test_method(self, value1, value2):
> return value1 + value2
If the code is this simple and you want to test only a method I will
write a unittest for it and don't test using proteus.

IMHO Proteus should be used when testing full user interaction,
on_change functions or full workflows.

Markus Bala

unread,
Oct 18, 2016, 5:15:02 AM10/18/16
to Tryton
On Tue, Oct 18, 2016 at 3:44 PM, Sergi Almacellas Abellana <se...@koolpi.com> wrote:
El 18/10/16 a les 10:27, Markus Bala ha escrit:
Hi Sergi,

Example code as below, if in the proteus, how am I going to call
"test_method"?

Class stock_move:
    def test_method(self, value1, value2):
        return value1 + value2
If the code is this simple and you want to test only a method I will write a unittest for it and don't test using proteus.

IMHO Proteus should be used when testing full user interaction, on_change functions or full workflows.

Hi Sergi,

Sorry, I think I made you confuse.
I made 2 question in one email:

The 1st question is how to write and call unittest. I had already understand the concept and trying to understand by hand on.

The 2nd question is how to call method from proteus. --> This is not for Unit Test but for development.
How to call the method from proteus usign RPC?


Apologize again, to make you confuse





--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk

--
You received this message because you are subscribed to the Google Groups "tryton-dev" group.

Sergi Almacellas Abellana

unread,
Oct 18, 2016, 1:24:30 PM10/18/16
to tryto...@googlegroups.com
El 18/10/16 a les 11:14, Markus Bala ha escrit:
> Sorry, I think I made you confuse.
> I made 2 question in one email
>
Yes, i got confused by this fact.

> The 1st question is how to write and call unittest. I had already
> understand the concept and trying to understand by hand on.
So I think everything is solved, isn't it?
>
> The 2nd question is how to call method from proteus. --> This is not for
> Unit Test but for development.
> How to call the method from proteus usign RPC?
>

Could you please start a new thread for this unrelated question? Thanks
in advance.
Reply all
Reply to author
Forward
0 new messages