Search code examples
pythonpycharm

How to change the working directory in pycharm globally?


When I run a pytest script, the working directory is always the folder where this pytest script is in. But what I want is to make the project root folder as the working directory. Although I can change it in the Run configuraiton, but it only applied in for the single pytest, which means I need to do this change for each pytest. Is there any configuration to make a global configuration? Thanks


Solution

  • You can right-click on the folder you want to set as the root directory, then look in the menu for Mark Directory as, and choose Source Root.