Is it possible to run tests from multiple test directories?

I have a Django (if it matters) application, structured approximately this way.

/main
   /foo
     /class1.py
     /tests
       /test_class1.py
   /bar
     /class2.py
     /tests
       /test_class2.py

Under PyCharm's test configuration, it's no problem for me to test "All in folder".  Unfortunately, I'm restricted to testing one folder at a time.  I've tried...

a) combining the directories with my test files with
  i) a comma separator
  ii) a semicolon separator
b) using globs
  i) \main\*\tests
  ii) \main\**\tests

Neither of these worked for me.  I could set up a test configuration for each smaller application, but I know this will lead to me forgetting to run tests and making an embarrassing mistake Real Soon Now.

Is there a way to accomplish this or am I just doing everything completely wrong?
5 comments
Comment actions Permalink
Hi Dave,

please, try to use Django Tests run configuration instead of unittests one.
You may go to Run-> Edit configuration and create it manually (type target in appropriate field) or
just right click on application and select Run Django Tests (this is available if Settings->Django Support is correct)
0
Comment actions Permalink
Django support is enabled, the paths are correct and the files (manage.py and containerapp\settings.py) are both there and reference the two Django projects I added.  I'm not seeing a Run Django Tests option anywhere.

I tried to configure Django Tests to run everything.  According to http://www.jetbrains.com/pycharm/webhelp/run-debug-configuration-django-test.html "all the tests in all the applications specified in INSTALLED_APPS will be executed"; when I try it, I'm not seeing any tests executed, probably because I put them in a /tests sub-folder and not in tests.py.  Looking at the output from the test run, I see that PyCharm is attempting to assemble tests.py on the fly for me, but it's ultimately failing to find any.
0
Comment actions Permalink
I found the source of my initial problem problem - I had named the test subdirectory "test" and not "tests".  Renaming it fixed that much.

I'm left with a second problem - running this runs all the Django unit tests (which is pretty time-consuming) and a large number of them are failing, leaving me buried under noise.  In PyCharm's test configuration, I'm not able to target more than one of my applications.
0
Comment actions Permalink
Please, try to specify multiple targets using whitespace in Django Tests Run Configuration->Target
0
Comment actions Permalink
Thanks - putting a space between the projects lets me test multiple Django projects at once.
0

Please sign in to leave a comment.