Pycharm won't allow to run a file. Shows run unittest option only.

前端 未结 6 1498
猫巷女王i
猫巷女王i 2020-12-28 12:41

I have a file and it has bunch of methods starting with prefix \"test\". Now I want to run this file and it has a __name__ == \"__main__\" construct which sets

6条回答
  •  不思量自难忘°
    2020-12-28 12:56

    One detail missing from @yole’s answer is that you need to delete any existing configurations associated with the file before you can right-click and get it to run/debug. So, the full procedure is:

    1. Delete any existing configurations for that file by going to ‘Run -> Edit Configurations’ in the menu.
    2. Right click inside the if __name__ == '__main__': block
    3. Choose Run
    4. Save the configuration

    After that, you should be able to run or debug the file as expected.

提交回复
热议问题