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 jb_unittest_runner.py 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 .../_jb_unittest_runner.py --path  /path/to/my/test_script.py

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

 

 

2 comments
Comment actions Permalink
Official comment

Hello.

PyCharm does not provide API for that. You can iterate through ``sys.argv`` looking for your argument or create feature request: https://youtrack.jetbrains.com/issues

Comment actions Permalink

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

0

Please sign in to leave a comment.