aws-toolkit-jetbrains icon indicating copy to clipboard operation
aws-toolkit-jetbrains copied to clipboard

Can't use profile in PyCharm tests

Open RobinFrcd opened this issue 3 years ago • 3 comments

Describe the bug I'm trying to use a profile in my PyTest tests in PyCharm but it raises botocore.exceptions.NoCredentialsError: Unable to locate credentials.

It works well for a script I run directly, only broken in tests.

To reproduce

  1. Create a simple test
def test_s3():
    s3 = boto3.client("s3")
    s3.get_object(Bucket="foo", Key="Bar")
  1. Set the credentials in the AWS Connection tab of the test
  2. Run the test in PyCharm UI (by clicking the Play arrow)
  3. Should encounter botocore.exceptions.NoCredentialsError: Unable to locate credentials

Expected behavior Credentials should be located

Screenshots image

Your Environment

  • OS: MacOS 12.3.1
  • JetBrains product: PyCharm
  • JetBrains product version: 2022.1 (Professional Edition)
  • AWS Toolkit version: 1.43-221 Apr 28, 2022

RobinFrcd avatar May 11 '22 14:05 RobinFrcd

I need to trace this a bit further, but you can work around this by making an explicit "pytest" run configuration as opposed to the default "Autodetect"

image

rli avatar May 13 '22 06:05 rli

That's working, indeed ! Thanks ! :rocket:

And cheers again to the team for this awesome plugin, it saves me a lot of time!

RobinFrcd avatar May 13 '22 07:05 RobinFrcd

Reported issue to JetBrains: https://youtrack.jetbrains.com/issue/PY-54226

rli avatar May 13 '22 18:05 rli