Exemplo n.º 1
0
            path)
        if sys.version_info > (3, 0) and os.path.isfile(path):
            # In Py3 it is possible to run script directly which is much more stable than discovery machinery
            # For example it supports hyphens in file names PY-23549
            additional_args = [path] + additional_args
        else:
            discovery_args = ["discover", "-s"]
            # Unittest in py2 does not support running script directly (and folders in py2 and py3),
            # but it can use "discover" to find all tests in some folder (optionally filtering by script)
            if os.path.isfile(path):
                discovery_args += [
                    os.path.dirname(path), "-p",
                    os.path.basename(path)
                ]
            else:
                discovery_args.append(path)
            discovery_args += [
                "-t", os.getcwd()
            ]  # To force unit calculate path relative to this folder
            additional_args = discovery_args + additional_args
    elif targets:
        additional_args += targets
    args += additional_args
    jb_doc_args("unittests", args)
    # Working dir should be on path, that is how unittest work when launched from command line
    sys.path.append(os.getcwd())
    main(argv=args,
         module=None,
         testRunner=unittestpy.TeamcityTestRunner,
         buffer=not JB_DISABLE_BUFFERING)
# coding=utf-8
import re

import nose
import sys

from _jb_runner_tools import jb_start_tests, jb_patch_separator, jb_doc_args
from teamcity.nose_report import TeamcityReport

if __name__ == '__main__':
    path, targets, additional_args = jb_start_tests()
    sys.argv += [path] if path else jb_patch_separator(targets, fs_glue="/", python_glue=".", fs_to_python_glue=".py:")
    sys.argv += additional_args
    jb_doc_args("Nosetest", sys.argv)
    nose.main(addplugins=[TeamcityReport()])
# coding=utf-8
import os
from pprint import pprint

from _jb_runner_tools import jb_start_tests, jb_doc_args
from twisted.scripts import trial
import sys

if __name__ == '__main__':
    # This folder should be in sys.path because teamcity twisted plugin is there
    sys.path.append(os.path.join(os.path.dirname(__file__),
                                 "__jb.for_twisted"))

    path, targets, additional_args = jb_start_tests()

    sys.path.append(
        os.getcwd())  # Current dir must be in sys.path according to trial docs

    sys.argv.append("--reporter=teamcity")
    sys.argv += additional_args

    if path:
        assert os.path.exists(path), path + " does not exist"
        # assert os.path.isfile(path), path + " is folder. Provide its name as python target (dot separated)"
        sys.argv.append(os.path.normpath(path))
    elif targets:
        sys.argv += targets

    jb_doc_args("trial", sys.argv[1:])
    trial.run()
Exemplo n.º 4
0
    # plugin is discovered automatically in 3, but not in 2
    # to prevent "plugin already registered" problem we check it first
    plugins_to_load = []
    if not get_plugin_manager().hasplugin("pytest-teamcity"):
        if "pytest-teamcity" not in map(lambda e: e.name, iter_entry_points(group='pytest11', name=None)):
            plugins_to_load.append(pytest_plugin)

    args = sys.argv[1:]
    if "--jb-show-summary" in args:
        args.remove("--jb-show-summary")
    elif int(pytest.__version__.split('.')[0]) >= 6:
        args += ["--no-header", "--no-summary", "-q"]

    if JB_DISABLE_BUFFERING and "-s" not in args:
      args += ["-s"]


    jb_doc_args("pytest", args)


    class Plugin:
        @staticmethod
        def pytest_configure(config):
            if getattr(config.option, "numprocesses", None):
                set_parallel_mode()
            start_protocol()

    os.environ["_JB_PPRINT_PRIMITIVES"] = "1"
    sys.exit(pytest.main(args, plugins_to_load + [Plugin]))
    path, targets, additional_args = parse_arguments()
    sys.argv += additional_args
    joined_targets = jb_patch_separator(targets, fs_glue="/", python_glue="::", fs_to_python_glue=".py::")
    # When file is launched in pytest it should be file.py: you can't provide it as bare module
    joined_targets = [t + ".py" if ":" not in t else t for t in joined_targets]
    sys.argv += [path] if path else joined_targets

    # plugin is discovered automatically in 3, but not in 2
    # to prevent "plugin already registered" problem we check it first
    plugins_to_load = []
    if not get_plugin_manager().hasplugin("pytest-teamcity"):
        if "pytest-teamcity" not in map(lambda e: e.name, iter_entry_points(group='pytest11', name=None)):
            plugins_to_load.append(pytest_plugin)

    args = sys.argv[1:]
    if JB_DISABLE_BUFFERING and "-s" not in args:
        args += ["-s"]

    jb_doc_args("pytest", args)
    # We need to preparse numprocesses because user may set it using ini file
    config_result = real_prepare_config(args, plugins_to_load)

    if getattr(config_result.option, "numprocesses", None):
        set_parallel_mode()

    config._prepareconfig = lambda _, __: config_result

    start_protocol()
    pytest.main(args, plugins_to_load)
Exemplo n.º 6
0
# coding=utf-8
import re
import sys

import pytest
from _pytest.config import _prepareconfig

from _jb_runner_tools import jb_start_tests, jb_patch_separator, jb_doc_args
from teamcity import pytest_plugin

if __name__ == '__main__':
    path, targets, additional_args = jb_start_tests()
    sys.argv += additional_args
    joined_targets = jb_patch_separator(targets,
                                        fs_glue="/",
                                        python_glue="::",
                                        fs_to_python_glue=".py::")
    # When file is launched in py.test it should be file.py: you can't provide it as bare module
    joined_targets = [t + ".py" if ":" not in t else t for t in joined_targets]
    sys.argv += [path] if path else joined_targets
    jb_doc_args("py.test", sys.argv[1:])

    # plugin is discovered automatically in 3, but not in 2
    # to prevent "plugin already registered" problem we check it first
    plugins_to_load = []
    if not _prepareconfig().pluginmanager.hasplugin("pytest-teamcity"):
        plugins_to_load.append(pytest_plugin)
    pytest.main(sys.argv[1:], plugins_to_load)
from _jb_runner_tools import jb_start_tests, jb_doc_args, JB_DISABLE_BUFFERING
from teamcity import unittestpy

if __name__ == '__main__':
    path, targets, additional_args = jb_start_tests()

    args = ["python -m unittest"]
    if path:
        assert os.path.exists(path), "{0}: No such file or directory".format(path)
        if sys.version_info > (3, 0) and os.path.isfile(path):
            # In Py3 it is possible to run script directly which is much more stable than discovery machinery
            # For example it supports hyphens in file names PY-23549
            additional_args = [path] + additional_args
        else:
            discovery_args = ["discover", "-s"]
            # Unittest in py2 does not support running script directly (and folders in py2 and py3),
            # but it can use "discover" to find all tests in some folder (optionally filtering by script)
            if os.path.isfile(path):
                discovery_args += [os.path.dirname(path), "-p", os.path.basename(path)]
            else:
                discovery_args.append(path)
            discovery_args += ["-t", os.getcwd()]  # To force unit calculate path relative to this folder
            additional_args = discovery_args + additional_args
    elif targets:
        additional_args += targets
    args += additional_args
    jb_doc_args("unittests", args)
    # Working dir should be on path, that is how unittest work when launched from command line
    sys.path.insert(0, os.getcwd())
    main(argv=args, module=None, testRunner=unittestpy.TeamcityTestRunner, buffer=not JB_DISABLE_BUFFERING)
# coding=utf-8
import re

import nose
import sys

from _jb_runner_tools import jb_start_tests, jb_patch_separator, jb_doc_args, JB_DISABLE_BUFFERING
from teamcity.nose_report import TeamcityReport

if __name__ == '__main__':
    path, targets, additional_args = jb_start_tests()
    sys.argv += [path] if path else jb_patch_separator(targets, fs_glue="/", python_glue=".", fs_to_python_glue=".py:")
    sys.argv += additional_args
    if JB_DISABLE_BUFFERING and "-s" not in sys.argv:
        sys.argv += ["-s"]
    jb_doc_args("Nosetest", sys.argv)
    nose.main(addplugins=[TeamcityReport()])
# coding=utf-8
import os
from pprint import pprint

from _jb_runner_tools import jb_start_tests, jb_doc_args
from twisted.scripts import trial
import sys


if __name__ == '__main__':
    # This folder should be in sys.path because teamcity twisted plugin is there
    sys.path.append(os.path.join(os.path.dirname(__file__), "__jb.for_twisted"))

    path, targets, additional_args = jb_start_tests()

    sys.path.append(os.getcwd()) # Current dir must be in sys.path according to trial docs

    sys.argv.append("--reporter=teamcity")
    sys.argv += additional_args

    if path:
        assert os.path.exists(path), path + " does not exist"
        # assert os.path.isfile(path), path + " is folder. Provide its name as python target (dot separated)"
        sys.argv.append(os.path.normpath(path))
    elif targets:
        sys.argv += targets

    jb_doc_args("trial", sys.argv[1:])
    trial.run()