How to run tests for an Add-in using pytest

How to run tests for an Add-in using pytest

marti_isern_09
Observer Observer
323 Views
2 Replies
Message 1 of 3

How to run tests for an Add-in using pytest

marti_isern_09
Observer
Observer

I am working on a fusion 360 add-in as the final project of the CS50 Python course. One of the project requirements is that it must have 3 functions that can be tested using pytest. However, I have know idea on where to start and how to make it work. I don't even know if it is possible.

I would like some guidance about this topic before I dedicate too much time on the project itself. 

Thank you!

 

Additional information:

All the CS50 python course exercices (including the project) are coded and submitted through a github codespace (in the cloud).

 

Edit: Also, when I import the add-in in the github codespace it shows the error that the adsk.core module fails to be imported. If anyone knows how to solve that it would be useful too. 

0 Likes
324 Views
2 Replies
Replies (2)
Message 2 of 3

hajime2MRG3
Enthusiast
Enthusiast

I have some experience with unittest. There is a hard-to-foresee pitfall with your task (and it will be irrelevant with your interest). I just mention about it.

Use only a .py file which Fusion creates (refer to the file as root .py file). Don't create/write any other .py files. In other words, don't import your .py files.

Why? Fusion add-in and script system reloads root .py file as needed. But do nothing with other .py files. You'll need to reopen Fusion to reload such .py files. (There is a hack to reload, but it is not a CS thing.) It is a big pain. So use only a root .py file.

0 Likes
Message 3 of 3

marti_isern_09
Observer
Observer
Thank you for warning. I'll stick to only one .py file then
0 Likes