1__author__ = 'ktisha'
2
3import sys
4from pycharm_run_utils import PYTHON_VERSION_MAJOR, PYTHON_VERSION_MINOR
5#noinspection PyUnresolvedReferences
6import pycharm_commands  # we need pycharm_commands module to be loaded
7
8if __name__ == "__main__":
9    parameters = []
10
11    test_suite = sys.argv.pop(-1)
12    while test_suite.startswith("-"):
13      parameters.append(test_suite)
14      test_suite = sys.argv.pop(-1)
15
16    sys.argv = [test_suite, "--command-packages", "pycharm_commands", "pycharm_test"]
17    sys.argv.extend(parameters)
18    __file__ = test_suite
19
20    if PYTHON_VERSION_MINOR == 2 and PYTHON_VERSION_MAJOR == 4:
21        #noinspection PyCompatibility
22        execfile(test_suite)
23    else:
24        #noinspection PyCompatibility
25        with open(test_suite, "r") as fh:
26            exec (fh.read(), globals(), locals())
27