Pycharm run select unittests

I have a python package where all my unittest test classes are stored in modules in a subpackage mypkg.tests. In the file tests/__init__.py, I have a function called suite. I usually run these tests, calling python setup.py testwhich one test_suite='satpy.tests.suite'. Can I run this test suite from pycharm?

The reason I have a recruitment function is because it contains only those tests that are ready to run from my continuous integration, but there are other unsuccessful tests in this directory (from older versions of the package). I could also see that it is useful for choosing quick unittests and lengthy tests. I tried working as a script, like nosetest or unittest configuration. I tried to add if __name__ == "__main__":other types of running command line methods without success.

Is there a way to run only some tests from the pycharm launch configuration?

+4
source share
1 answer

Pycharm 'Python Unittest' unittest.TestLoader . Pycharm , , TestSuite, , .

- load_tests tests/__init__.py, :

def load_tests(loader, tests, pattern):
    return suite()

pycharm 'Script' tests/__init__.py

load_tests , :)

: https://docs.python.org/2.7/library/unittest.html#load-tests-protocol

, python 2.7 .

0

All Articles