Problem whit torizonExtension when debugging pytest code in VScode

Hi,
in VS code when I try to run pytest in debug mode, the Torizon extension is trying to reach some devices and run the debug code there.
I don’t think this is the proper behaviour, is there a way to fix it?

Regards,
Rocco

Hi @RoccoBr ,

The Torizon extension allows you to do remote-rebugging on the devices. So you can write code and test it immediately on the devices.

Would it be possible for you to elaborate a bit more on what behaviour you are seeing, as well as what you are expecting?

Do you have screenshots of the behavior you’re seeing?

Best Regards
Kevin

hi @kevin.tx ,
pytest framework is supposed to run inside VScode only, not on an actual device

Regards,
Rocco

1 Like

Hi @RoccoBr !

Could you please share the following information:

  • Which OS are you using on your development machine? Also which version?
  • Which version of Torizon Extension for VSCode are you using?
  • Could you share a minimal project the reproduces the error you are facing?

Best regards,

I’m using VS code v1.69.1 (latest) on Windows machine. toradex torizon support v1.5.1.

I can’t give you a project because you need first to configure pytest manually in your VScode environment (see previous link how to configure it Testing Python in Visual Studio Code), but to reproduce the error is quite straightforward:

  • create a simple python function (print something)
    -configure pytest in VS code
    -write a test_module.py with a test_function() where the simple function is called
  • put a breakpoint inside test_function()
  • run test_module.py in debug mode

you will see that the Torizon extension will try to run the code on a device, when instead it shouldn’t interfere at all with the pytest framework

if you are more comfortable with unittest instead of pytest, you can reproduce the same wrong behaviour using the same step above

Regards,
Rocco

Hi @RoccoBr, how are you?

I wanted to let you aware that we are currently trying to reproduce this on our side with the help of our colleagues from the extension team and we’ll come back to you once we have proper news.

Best regards,

1 Like

hi @gclaudino.tx ,
more details in order to reproduce the error:

  • create a simple application (docker container) that you can run in debug mode on an actual SOM via torizon Extension

  • configure pytest in VS code and create a simple test as explained before.

Regards,
Rocco

1 Like

hi @gclaudino.tx ,
we have found a temporary workaround disabling the Torizon plugin in the extensions list and rebooting VS code, at that point we can run pytest in debug mode.
nevertheless, it would be better that Torizon extension doesn’t interfere with the pytest framework.

Regards,
Rocco

Hi @RoccoBr,

Thanks for the updates. I’ve also forwarded them to the responsible team that is working on it.

Best regards,

Hi @RoccoBr, how are you?

I just got new feedback from our IDE Extensions Team. They investigated the topic and the issue is that when one creates a Torizon project with VSCode there are some Workspace configurations that are made even before executing the launch.json. The extension understands by default that you want to run the code on the device and this is the origin of the issue you presented.

Therefore, the team has thought of two paths for you at the moment:

  1. Keep with the workaround you’re using of disabling the Torizon Extension
  2. Create a second workspace. On one, you’ll have everything to run the code on the module and on the other you can use it to debug on the host machine using Pytest.

Would any of these two options be suitable for you? What do you think about it?

hi @gclaudino.tx ,
thanks for the support. I think the simplest thing is to disable the extension when I need to run pytest in debug mode.

Regards,
Rocco

1 Like