Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pytest run config overridden by lambda run config when tests have two parameters #1011

Closed
cfriedline opened this issue Jun 6, 2019 · 10 comments
Labels
bug We can reproduce the issue and confirmed it is a bug.
Milestone

Comments

@cfriedline
Copy link

cfriedline commented Jun 6, 2019

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.
@zhangzhx
Copy link
Contributor

zhangzhx commented Jun 8, 2019

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.

@zhangzhx zhangzhx added the bug We can reproduce the issue and confirmed it is a bug. label Jun 8, 2019
@abrooksv abrooksv added needs-response Waiting on additional info and feedback from GitHub community. (no auto closure) and removed bug We can reproduce the issue and confirmed it is a bug. labels Jun 13, 2019
@cfriedline
Copy link
Author

cfriedline commented Jun 26, 2019

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.

@abrooksv abrooksv added investigating and removed needs-response Waiting on additional info and feedback from GitHub community. (no auto closure) labels Jun 27, 2019
@abrooksv
Copy link
Contributor

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

@abrooksv abrooksv added this to the Sprint 27 milestone Jun 27, 2019
@dylanjcastillo
Copy link

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

@abrooksv
Copy link
Contributor

abrooksv commented Nov 14, 2019

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

@curtiscook
Copy link

curtiscook commented Mar 27, 2020

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

@abrooksv abrooksv added bug We can reproduce the issue and confirmed it is a bug. and removed investigating labels Apr 7, 2020
@abrooksv
Copy link
Contributor

abrooksv commented Apr 7, 2020

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

@abrooksv
Copy link
Contributor

abrooksv commented Apr 7, 2020

Change has been released in 1.12

@abrooksv
Copy link
Contributor

abrooksv commented Apr 7, 2020

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

@curtiscook
Copy link

awesome, thanks!

Will-ShaoHua pushed a commit to Will-ShaoHua/aws-toolkit-jetbrains that referenced this issue Mar 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug We can reproduce the issue and confirmed it is a bug.
Projects
None yet
Development

No branches or pull requests

6 participants