How to get test name from jb_unittest_runner

I'm having problems getting pycharm to run our unittests, which run fine from the command line. The issue is that the tests expect that sys.argv[0] is the name of the test script, but because the test is actually run by our tests fail.  I understand from the posts I've found that there are issues submitted to address this, but I would like to know if there is something that I can add to our tests to get the name of the test script being run.

For instance, the command which runs the tests is something like this:

python2.7 .../ --path  /path/to/my/

What I want is a way from within to get the value passed to with the --path option.



Comment actions Permalink
Official comment


PyCharm does not provide API for that. You can iterate through ``sys.argv`` looking for your argument or create feature request:

Comment actions Permalink

Sorry, I realized that I oversimplified my example. Our test scripts ( all import another file ( It is in where we would need to get the name of the test script. (Otherwise we could just use __file__.)


Please sign in to leave a comment.