PyCharm 2017.1 issue with running tests in subfolders (from UI) workaround

Noticed this after updating to PyCharm 2017.1. We ran some of our tests by right clicking on a top level folder then selecting “Run Nosetests in ..” from the right click menu. This does not work any more as the right click option is missing, unless you have tests in all subfolders.

Here is a workaround that worked for me. I do not necessarily recommend it, but it does the job: Place a fake test file in the top level directory. I tried in several combinations but it seems like just placing in top level directory that you want to run from is enough. Try it. If not, then place in all subfolders.

This is how my fake_test.py looks like. When running, it completes in 1ms so not a time hog.


import unittest
class FakeTest(unittest.TestCase):
    def setUp(self):
        pass
    def test_nothing(self):
        pass
    def tearDown(self):
        pass

Below are also some images to illustrate the point better. I have three levels of folders. I captured the screenshot of right click menu for low/mid/top level folders. Only the low level has a real test file. The others do not. By placing a fake_test.py file in the mid level, one can run tests from UI from the mid level right click menu. In the last image you can also see that the menu option “Run Nosetests in ..” is missing from the top level as it does not have any test files.

Hope this helps someone.Pycharm_test_folders_001
Pycharm_test_folders_002
Pycharm_test_folders_003