How to run unit tests from different locations?

Hello.

I am new to PyCharm. In my project in each package there is a directory tests with tests for classes of this package.

Is there any way I can run all tests from all "tests" directories? Maybe there is a better way to place my tests to run them all in once?

Thank you in advance.

4 comments
Comment actions Permalink

Hi Ivan,

you can use "Run all tests in the folder.." test run configuration and specify pattern for your test files.

By the way, it's more convenient to put all tests in one package.

0
Comment actions Permalink

Hello.

Thank you for your response. It helped. Now I can run all tests in one.

I am not very experienced in Python, so I take a look an NumPy and saw that they create "test" directory in every packages for tests and decided to try this.

By putting all tests in one package you mean to do it in Maven-like style( Directory with packages for code, directory with packages for tests. If there is a package a.b.c it's in main/src/a/b/c and it's tests are in tests/src/a/b/c/.)?

0
Comment actions Permalink

Hi,

there is no "must do" way for python unittests =)

Yes, I meant kind of maven style. I believe it's easier to test your code if tests are placed in one directory.

try to check this article: http://infinitemonkeycorps.net/docs/pph/

or some popular project :

http://code.djangoproject.com/svn/django/trunk/
http://code.google.com/p/python-nose

Hope, you'll find your way.

0
Comment actions Permalink

Thank you for the article and for links. They are usefull to me.

0

Please sign in to leave a comment.