pytest and nosetest added

This commit is contained in:
Ilya.Kazakevich
2015-12-09 23:17:21 +03:00
parent e8570dfa45
commit 0f84357714
+32 -18
View File
@@ -1,7 +1,8 @@
# coding=utf-8
"""
Runs tox from current directory.
It supports any runner, but well-known runners (py.test and unittest) are switched to our internal runners to provide better support
It supports any runner, but well-known runners (py.test and unittest) are switched to our internal runners to provide
better support
"""
import os
import sys
@@ -13,12 +14,30 @@ from tcmessages import TeamcityServiceMessages
helpers_dir = str(os.path.split(__file__)[0])
# Placeholder to insert arguments
__ARGUMENTS_KEY = "__jb_place_for_arguments"
class _Unit2(object):
def fix(self, command):
if command[0] != "unit2":
return None
return [os.path.join(helpers_dir, "utrunner.py"), os.getcwd()] + command[1:] + ["true"]
# List of local runners to use
_RUNNERS = {"unit2": [os.path.join(helpers_dir, "utrunner.py"), os.getcwd(), __ARGUMENTS_KEY, "true"]}
class _PyTest(object):
def fix(self, command):
if command[0] != "py.test":
return None
return [os.path.join(helpers_dir, "pytestrunner.py"), "-p", "pytest_teamcity", os.getcwd()] + command[1:]
class _Nose(object):
def fix(self, command):
if command[0] != "nosetests":
return None
return [os.path.join(helpers_dir, "noserunner.py"), os.getcwd()] + command[1:]
_RUNNERS = [_Unit2(), _PyTest(), _Nose()]
teamcity = TeamcityServiceMessages()
@@ -60,19 +79,14 @@ for env, tmp_config in config.envconfigs.items():
tmp_config.setenv = dict()
tmp_config.setenv.update({"_jb_do_not_call_enter_matrix": "1"})
commands = tmp_config.commands
if isinstance(commands, list) and len(commands):
command_with_arguments = commands[0]
command = command_with_arguments[0]
arguments = command_with_arguments[1:]
if command in _RUNNERS:
command_with_arguments = list(_RUNNERS[command_with_arguments[0]])
index_key = command_with_arguments.index(__ARGUMENTS_KEY)
if index_key:
if arguments:
command_with_arguments[index_key:index_key + len(arguments)] = arguments
else:
command_with_arguments[index_key:index_key+1] = []
tmp_config.commands = [command_with_arguments]
if not isinstance(commands, list) or not len(commands):
continue
for fixer in _RUNNERS:
for i, command in enumerate(commands):
fixed_command = fixer.fix(command)
if fixed_command:
commands[i] = fixed_command
tmp_config.commands = commands
session = tox_session.Session(config, Report=_Reporter)
teamcity.testMatrixEntered()