Aws-toolkit-jetbrains: Pytest run config overridden by lambda run config when tests have two parameters

Created on 6 Jun 2019  路  10Comments  路  Source: aws/aws-toolkit-jetbrains

Describe the bug
In an existing code base with lots of pytest tests, after installing the AWS toolkit, the run configurations for tests with two input parameters (i.e., fixtures) show up as lambdas and launch the lambda run config when clicking the play icon. However, tests which do not have two parameters do not have this problem.

image

image

image

To reproduce

  1. Open pytest file
  2. Create a new test and fixtures
  3. Attempt to run test_anything(), gets lambda popup
  4. Attempt to run test_anything2(), runs pytest as expected

Expected behavior
In both cases, pytest should run the test and not cause the lambda run configuration dialog to come up

Your Environment

  • OS: MacOS 10.14.5
  • JetBrains' Product: PyCharm
  • JetBrains' Product Version: 2019.1.3
  • Toolkit Version: 1.3 and 1.4-EAP.2019.05.29
  • SAM CLI Version: 0.16.1
  • JVM/Python Version: 3.7 in conda environment for the application code, sam installed /usr/local/bin/python -> ../../../Library/Frameworks/Python.framework/Versions/2.7/bin/python which is 2.7.16. This is the version that gets called by PyCharm, despite having sam installed in the project's conda environment.
bug

Most helpful comment

Here is the old youtrack issue that is the root cause: youtrack.jetbrains.com/issue/IDEA-135770
We do not have a workaround yet, we may have to put in some heuristic to disable it or something along those lines
Edit: As in the youtrack, you can use Ctrl+Alt+R (on OS X) to work around it for now

Is there any update on this? It looks like the youtrack is 5 years old so it feels lost in the backlog.

One thing to note, the UI looks like it wants to run pytest, but then Pycharm choses to try to generate an AWS Lambda

Ctrl-Alt-R sets up the configuration correctly and then you can use the play button after, but that's not a great workaround, since the issue is per test function and not per file

Screen Shot 2020-03-27 at 3 19 09 PM

Edit: it seems the best workaround is to completely uninstall the AWS toolkit, which fixes the issue

Sorry for being quiet, this fell through the cracks and I apologize.

We are going to work around the IntelliJ bug and add checks in our logic:

  1. Ignore any handler candidates that that are in a folder marked as a test root
  2. Ignore any handler candidates that start with test_ to avoid conflicting with pytest logic

All 10 comments

Can you double check to see if you enabled the AWS setting Show gutter icons for all potential AWS Lambda handlers?

You can do this by PyCharm -> Preferences -> Tools -> AWS -> Project settings. For a workaround, you can turn off this check to avoid the Toolkit recognizing arbitrary suspicious functions.

Thanks @zhangzhx. Indeed, I can turn off the gutter icons. However, even after I do that, when I click the play button on the test, even though it says "run pytest..." it still launches the dialog to run as if it were a lambda.

I should mention that I am now using the aws toolkit version 1.4. sam version 0.17.0.

That sounds super strange, we will need to dig into that discrepancy

Hey guys, I'm getting the same issue. Have you find any workaround for this?

Here is the old youtrack issue that is the root cause: https://youtrack.jetbrains.com/issue/IDEA-135770

We do not have a workaround yet, we may have to put in some heuristic to disable it or something along those lines

Edit: As in the youtrack, you can use Ctrl+Alt+R (on OS X) to work around it for now

Here is the old youtrack issue that is the root cause: https://youtrack.jetbrains.com/issue/IDEA-135770

We do not have a workaround yet, we may have to put in some heuristic to disable it or something along those lines

Edit: As in the youtrack, you can use Ctrl+Alt+R (on OS X) to work around it for now

Is there any update on this? It looks like the youtrack is 5 years old so it feels lost in the backlog.

One thing to note, the UI looks like it wants to run pytest, but then Pycharm choses to try to generate an AWS Lambda

Ctrl-Alt-R sets up the configuration correctly and then you can use the play button after, but that's not a great workaround, since the issue is per test function and not per file

Screen Shot 2020-03-27 at 3 19 09 PM

Edit: it seems the best workaround is to completely uninstall the AWS toolkit, which fixes the issue

Here is the old youtrack issue that is the root cause: youtrack.jetbrains.com/issue/IDEA-135770
We do not have a workaround yet, we may have to put in some heuristic to disable it or something along those lines
Edit: As in the youtrack, you can use Ctrl+Alt+R (on OS X) to work around it for now

Is there any update on this? It looks like the youtrack is 5 years old so it feels lost in the backlog.

One thing to note, the UI looks like it wants to run pytest, but then Pycharm choses to try to generate an AWS Lambda

Ctrl-Alt-R sets up the configuration correctly and then you can use the play button after, but that's not a great workaround, since the issue is per test function and not per file

Screen Shot 2020-03-27 at 3 19 09 PM

Edit: it seems the best workaround is to completely uninstall the AWS toolkit, which fixes the issue

Sorry for being quiet, this fell through the cracks and I apologize.

We are going to work around the IntelliJ bug and add checks in our logic:

  1. Ignore any handler candidates that that are in a folder marked as a test root
  2. Ignore any handler candidates that start with test_ to avoid conflicting with pytest logic

Change has been released in 1.12

Please re-open if the issue is still showing up with v1.12

awesome, thanks!

Was this page helpful?
0 / 5 - 0 ratings