Pycharm 2020.1 not retaining testing template configs

Hi guys,

I updated my PyCharm today, and I noticed that when testing modules via the IDE they're not retaining the configurations I set in the template anymore. I already cleaned up my project by deleting ".idea/" (I did that because the debugger had stopped working after the update, actually), but that didn't work.

Any ideas? This bug essentially makes me unable to test my project with PyCharm, which is quite frustrating - I can't just keep updating run configs every time I want to test a specific module.

Thanks,

Diogo

0
5 comments

Hi,

Do you mean run configuration template or run configuration itself?
Are there any relevant errors in the log (Help | Show Log in...) when it happens?

0

Hi Sergey,

This is what I did, in order to run my tests inside PyCharm, which I did for previous versions of the IDE as well:

  1. I setup the default test runner as py.test (in the IDE settings)
  2. I changed the py.test template configuration to use a specific environment variable (let's call it "DJANGO_SETTINGS_MODULE=myproject.foo_settings")
  3. I right-clicked the file (tried in the file browser on the left pane and on the file tab at the top) and asked the IDE to run the tests for that file

However, when the test is run, the environment variable is not being picked as per the template configuration, but rather it uses the "placeholder" one from my project ("os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings')"). This means that the configurations I've given the template are not being ported over to the tests I run for the files, from within PyCharm, including that environment variable.

I see nothing relevant in the output from the test execution, just the PyCharm's pytest runner running the test for the script I asked it to.

What do you think?

Cheers,

Diogo

0

Found it!!!

So, the problem is that I had the "Django support" project setting enabled, but that configuration overwrites the test template. This is a bug, because in "Django support" you can only specify one settings module, while I (and probably a lot more people) use one settings file for running my project locally and another for running the tests. In previous versions, it worked as I expected: the test template overwrites the project setting, letting me set the settings file I need.

Anyway, disabling that option works for me.

Thanks!

Diogo

0

Is it reproducible only with tests or with Django Server run configuration as well?
If first, would it be possible to provide us with the project sample?

0

Hi Sergey,

Sorry for the embarrassingly long delay, I've been too busy with work stuff...

So, I tested running a Django server with an app, using PyCharm Pro 2020.1.1 (latest version), and it works fine; If I define a settings file in the "Django support" setting in PyCharm, but then create an env var in my run configuration, the run configuration does overwrite the PyCharm setting as I expect it to.

Thanks!

Diogo

0

Please sign in to leave a comment.