本文整理汇总了Python中teamcity.is_running_under_teamcity函数的典型用法代码示例。如果您正苦于以下问题:Python is_running_under_teamcity函数的具体用法?Python is_running_under_teamcity怎么用?Python is_running_under_teamcity使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_running_under_teamcity函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: configure
def configure(self, options, conf):
self.enabled = is_running_under_teamcity()
self.config = conf
if self._capture_plugin_enabled():
capture_plugin = self._get_capture_plugin()
old_before_test = capture_plugin.beforeTest
old_after_test = capture_plugin.afterTest
old_format_error = capture_plugin.formatError
def newCaptureBeforeTest(test):
rv = old_before_test(test)
test_id = self.get_test_id(test)
capture_plugin._buf = FlushingStringIO(lambda data: dump_test_stdout(self.messages, test_id, test_id, data))
sys.stdout = capture_plugin._buf
return rv
def newCaptureAfterTest(test):
if isinstance(capture_plugin._buf, FlushingStringIO):
capture_plugin._buf.flush()
return old_after_test(test)
def newCaptureFormatError(test, err):
if isinstance(capture_plugin._buf, FlushingStringIO):
capture_plugin._buf.flush()
return old_format_error(test, err)
capture_plugin.beforeTest = newCaptureBeforeTest
capture_plugin.afterTest = newCaptureAfterTest
capture_plugin.formatError = newCaptureFormatError
示例2: pytest_runtest_teardown
def pytest_runtest_teardown(item: pytest.Item):
'''Hook to run after every test.'''
# Inject footer at end of test, may be followed by additional teardown.
# Don't do this when running in teamcity, where it's redundant.
if not teamcity.is_running_under_teamcity():
print('''
==========
======= END: {}::{}
=========='''.format(sdk_diag.get_test_suite_name(item), item.name))
示例3: add_options
def add_options(cls, parser):
cls._add_option(parser,
'--teamcity',
default=is_running_under_teamcity(),
help="Force output of JetBrains TeamCity service messages")
cls._add_option(parser,
'--no-teamcity',
default=False,
help="Disable output of JetBrains TeamCity service messages (even under TeamCity build)")
示例4: pytest_runtest_setup
def pytest_runtest_setup(item: pytest.Item):
'''Hook to run before every test.'''
# Inject header at start of test, following automatic "path/to/test_file.py::test_name":
# Don't do this when running in teamcity, where it's redundant.
if not teamcity.is_running_under_teamcity():
print('''
==========
======= START: {}::{}
=========='''.format(sdk_diag.get_test_suite_name(item), item.name))
if INTEGRATION_TEST_LOG_COLLECTION:
sdk_diag.handle_test_setup(item)
sdk_utils.check_dcos_min_version_mark(item)
示例5: main
def main():
parser = argparse.ArgumentParser(description="Run cppcheck")
parser.add_argument("--ac", type=str, help="Additional checks (default all)", default="all")
parser.add_argument("--idir", type=str, help="Path of file with all include directories", default="include_directories.txt")
parser.add_argument("--ip", type=argparse.FileType("r"), help="Path of file with directories to analyze", default="include_paths.txt")
parser.add_argument("--idef", type=argparse.FileType("r"), help="Path of file with included definitions", default="include_defines.txt")
parser.add_argument("--xp", type=argparse.FileType("r"), help="Path of file with directories or files to exclude from analysis", default="exclude_paths.txt")
parser.add_argument("--xdef", type=argparse.FileType("r"), help="Path of file with definitions to exclude", default="exclude_defines.txt")
parser.add_argument("--s", type=str, help="Path of file with warnings to suppress", default="suppressions.txt")
parser.add_argument("--ot", type=str, help="The output template", default=None)
parser.add_argument("--ext", type=str, help="Direct cppcheck arguments", default=None)
# get all data from command line
args = parser.parse_args()
# if the output format is None identify whether under TC or not and set message format accordingly
# if format set to TC will also need to escape messages
if args.ot is None:
if teamcity.is_running_under_teamcity():
args.ot = "tc"
else:
args.ot = "vs"
arguments = " --inline-suppr --error-exitcode=-1 --inconclusive --force" + \
" --enable=" + args.ac + \
("" if args.ext is None else " " + args.ext) + \
create_exclude_defines_argument(args.xdef) + \
create_include_defines_argument(args.idef) + \
create_include_paths_argument(args.ip) + \
" --includes-file=" + args.idir + \
create_exclude_paths_argument(args.xp) + \
" --template=" + ('"##teamcity[buildProblem description=\'{file}:{line}: {severity} ({id}): {message}\']"' if args.ot == "tc" else args.ot) + \
" --suppressions-list=" + args.s
# run the process and redirect both stdout and stderr for further processing if needed
if args.ot == "tc":
process = subprocess.Popen(get_cppcheck_path() + arguments, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
while True:
more = handle_output_line(process.stdout.readline().decode())
if not more:
break
return process.returncode
else:
return subprocess.call(get_cppcheck_path() + arguments)
示例6: pytest_configure
def pytest_configure(config):
if config.option.no_teamcity >= 1:
enabled = False
elif config.option.teamcity >= 1:
enabled = True
else:
enabled = is_running_under_teamcity()
if enabled:
output_capture_enabled = getattr(config.option, 'capture', 'fd') != 'no'
coverage_controller = _get_coverage_controller(config)
skip_passed_output = bool(config.getini('skippassedoutput'))
config._teamcityReporting = EchoTeamCityMessages(
output_capture_enabled,
coverage_controller,
skip_passed_output,
bool(config.getini('swapdiff'))
)
config.pluginmanager.register(config._teamcityReporting)
示例7: __init__
def __init__(self):
self.loggers = []
if teamcity.is_running_under_teamcity():
self.loggers.append(TeamcityServiceMessages())
else:
self.loggers.append(PrintLogger())
示例8: TeamcityTestRunner
import sys
import unittest
try:
from teamcity import is_running_under_teamcity
from teamcity.unittestpy import TeamcityTestRunner
runner = TeamcityTestRunner() if is_running_under_teamcity() else unittest.TextTestRunner()
except ImportError:
runner = unittest.TextTestRunner()
from tests import ExampleTest
tests = {
"ExampleTest": ExampleTest
}
if __name__ == "__main__":
from application import application
application.start_testing()
test_name = sys.argv[1] if len(sys.argv) > 1 else None
tests = tuple(
[
unittest.loader.findTestCases(tests[test_suit_name])
for test_suit_name in tests
if test_suit_name == test_name or not test_name
]
)
sys.exit(not runner.run(unittest.TestSuite(tests=tests)).wasSuccessful())
示例9: parse_options
def parse_options(cls, options):
if not options.no_teamcity:
if options.teamcity or is_running_under_teamcity():
options.format = 'teamcity-messages'
示例10: run_suite
def run_suite(self, suite, **kwargs):
if is_running_under_teamcity():
return TeamcityTestRunner().run(suite)
else:
return unittest.TextTestRunner(
verbosity=self.verbosity, failfast=self.failfast).run(suite)
示例11: main_func
def main_func():
import argparse
parser = argparse.ArgumentParser(description="Bandwidth Wars")
parser.add_argument('--port',default=7171,type=int)
parser.add_argument('--turn_max',default=5,help="The maximum time allocated per turn",type=int)
parser.add_argument('--tokens',default=2,help="How many tokens should be generated for this game.",type=int)
parser.add_argument('--open-play',dest='open_play',action='store_true',help="Whether the server allows just anyone to play.")
parser.add_argument('--selftest',action='store_true',help="Run the tests.")
parser.add_argument('--teamcity',action='store_true',help="Using teamcity. Must be used with --selftest. teamcity-messages must be installed.")
parser.set_defaults(open_play=False)
args = parser.parse_args()
if args.selftest:
import teamcity
import teamcity.unittestpy
import unittest
if teamcity.is_running_under_teamcity() or args.teamcity:
runner = teamcity.unittestpy.TeamcityTestRunner()
else:
runner = unittest.TextTestRunner(verbosity=2)
import os.path
directory = os.path.dirname(__file__)
print "test directory",directory
testsuite = unittest.TestLoader().discover(directory)
runner.run(testsuite)
return
import models.game
game = models.game.Game(max_interval=args.turn_max,tokens=args.tokens,open_play=args.open_play)
from twisted.internet import protocol, reactor
import twisted.protocols.basic
class BW(twisted.protocols.basic.LineReceiver):
def __init__(self):
self.delimiter = '\n'
def connectionMade(self):
self.transport.write('{"msg":"Welcome to Bandwidth Wars","ver":0.1}\n')
def lineReceived(self, data):
if hasattr(self,"player"):
player = self.player.gameToken
else:
player = "???"
logging.debug("raw socket from %s> %s" % (player,data))
result = game.process_raw_command(data, self)
self.send_raw(result)
def send_raw(self,data):
if hasattr(self,"player") and self.player != None:
player = self.player.gameToken
else:
player = "???"
logging.debug("raw socket to %s> %s" % (player,data))
self.transport.write(data+"\n")
class BWFactory(protocol.Factory):
def buildProtocol(self, addr):
return BW()
logging.info("Listening on port %d",args.port)
reactor.listenTCP(args.port, BWFactory())
reactor.run()
示例12: is_running_under_teamcity
import pep8
from teamcity.messages import TeamcityServiceMessages
from teamcity import __version__, is_running_under_teamcity
name = 'teamcity_stats'
version = __version__
enable_teamcity = is_running_under_teamcity()
def add_options(parser):
parser.add_option('--teamcity_stats', default=False,
action='callback', callback=set_option_callback,
help="Enable teamcity stats messages")
def set_option_callback(option, opt, value, parser):
global enable_teamcity
enable_teamcity = True
def parse_options(options):
if not enable_teamcity:
return
options.reporter = TeamcityStatisticsReport
options.report = TeamcityStatisticsReport(options)
options.jobs = None # needs to be disabled, flake8 overrides the report if enabled
示例13: ImportError
if sys.version_info[:2] >= (3, 3, ):
from unittest import mock
else:
try:
import mock
except ImportError:
raise ImportError("The BatchApps Python Client test suite requires "
"the mock package to run on Python 3.2 and below.\n"
"Please install this package to continue.")
try:
from teamcity import is_running_under_teamcity
from teamcity.unittestpy import TeamcityTestRunner
TC_BUILD = is_running_under_teamcity()
except ImportError:
TC_BUILD = False
if __name__ == '__main__':
if TC_BUILD:
runner = TeamcityTestRunner()
else:
runner = TextTestRunner(verbosity=2)
test_dir = os.path.dirname(__file__)
top_dir = os.path.dirname(os.path.dirname(test_dir))
test_loader = TestLoader()
suite = test_loader.discover(test_dir,
示例14: run
def run(suite):
if is_running_under_teamcity():
runner = TeamcityTestRunner()
else:
runner = unittest.TextTestRunner()
runner.run(suite)
示例15: configure
def configure(self, options, conf):
self.enabled = is_running_under_teamcity()