Unable to run a single test file in tox

Answered

I'm able to run a single test file in tox from the command line

    tox tests/my_test.py

I create a Tox run configuration with the Arguments field set to either "tests/my_test.py" or "-- tests/my_test.py" but none works. All tests under the working directory are run.

 

IDEA 2016.3.5 / Python plugin 2016.3.163.298

Any way to get it work? Thanks

0
2 comments

Unfortunately it is not possible to run a single test file in tox, please feel free to file a feature request about it to Pycharm issue tracker: https://youtrack.jetbrains.com/issues/PY.

0
Avatar
Permanently deleted user

Ok, for a temporary work around, change the Nose runner command builder (or the other ones you use) in _jb_tox_runner.py (path can be seen at the top of the output console when running a tox configuraion) and then pass in your test file/class via environment variable.

I tried to extract the actual argument values but can't seem to find it.

class _Nose(object):
def fix(self, command, bin):
if command[0] != "nosetests":
return None
pytox_arg = os.getenv('PYC_TOX_ARG', None)
pytox_arg = [pytox_arg] if pytox_arg else []
return [bin, os.path.join(helpers_dir, "noserunner.py")] + command[1:] + pytox_arg
0

Please sign in to leave a comment.