当前位置: 首页>>代码示例>>Python>>正文


Python TeamcityServiceMessages.testFailed方法代码示例

本文整理汇总了Python中tcmessages.TeamcityServiceMessages.testFailed方法的典型用法代码示例。如果您正苦于以下问题:Python TeamcityServiceMessages.testFailed方法的具体用法?Python TeamcityServiceMessages.testFailed怎么用?Python TeamcityServiceMessages.testFailed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tcmessages.TeamcityServiceMessages的用法示例。


在下文中一共展示了TeamcityServiceMessages.testFailed方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TeamcityTestListener

# 需要导入模块: from tcmessages import TeamcityServiceMessages [as 别名]
# 或者: from tcmessages.TeamcityServiceMessages import testFailed [as 别名]
class TeamcityTestListener(TestListener):
    def __init__(self):
        self.messages = TeamcityServiceMessages(prepend_linebreak=True)

    def on_test_suite_start(self, test_suite):
        self.messages.testMatrixEntered()
        self.messages.testCount(len(test_suite.test_cases))

    def on_test_suite_finish(self, test_suite):
        pass

    def on_test_class_start(self, test_class):
        self.messages.testSuiteStarted(suiteName=test_class.full_name)

    def on_test_class_finish(self, test_class):
        self.messages.testSuiteFinished(suiteName=test_class.full_name)

    def on_test_group_start(self, test_group):
        if not hasattr(test_group.test_class, "is_group_feature_used") or test_group.test_class.is_group_feature_used:
            self.messages.testSuiteStarted(suiteName=test_group.name)

    def on_test_group_finish(self, test_group):
        if not hasattr(test_group.test_class, "is_group_feature_used") or test_group.test_class.is_group_feature_used:
            self.messages.testSuiteFinished(suiteName=test_group.name)

    def on_test_case_start(self, test_case):
        self.messages.testStarted(testName=test_case.name, location=test_case.location)

    def on_test_case_finish(self, test_case):
        if test_case.status == TestCaseStatus.FAILED:
            self.messages.testFailed(testName=test_case.name)
        elif test_case.status == TestCaseStatus.SKIPPED:
            self.messages.testIgnored(testName=test_case.name)
        self.messages.testFinished(testName=test_case.name, duration=int(test_case.elapsed_time * 1000.0))
开发者ID:KarlGong,项目名称:ptest-pycharm-plugin,代码行数:36,代码来源:ptestrunner.py

示例2: TeamcityTestResult

# 需要导入模块: from tcmessages import TeamcityServiceMessages [as 别名]
# 或者: from tcmessages.TeamcityServiceMessages import testFailed [as 别名]

#.........这里部分代码省略.........
        error_value = traceback.extract_tb(err)
        error_value = error_value[-1][-1]
        return error_value.split("assert")[-1].strip()

    def addFailure(self, test, err):
        location = self.init_suite(test)
        self.current_failed = True
        TestResult.addFailure(self, test, err)

        error_value = smart_str(err[1])
        if not len(error_value):
            # means it's test function and we have to extract value from traceback
            error_value = self.find_error_value(err[2])

        self_find_first = self.find_first(error_value)
        self_find_second = self.find_second(error_value)
        quotes = ["'", '"']
        if (
            self_find_first[0] == self_find_first[-1]
            and self_find_first[0] in quotes
            and self_find_second[0] == self_find_second[-1]
            and self_find_second[0] in quotes
        ):
            # let's unescape strings to show sexy multiline diff in PyCharm.
            # By default all caret return chars are escaped by testing framework
            first = self._unescape(self_find_first)
            second = self._unescape(self_find_second)
        else:
            first = second = ""
        err = self._exc_info_to_string(err, test)

        self.messages.testStarted(self.getTestName(test), location=location)
        duration = self.__getDuration(test)
        self.messages.testFailed(
            self.getTestName(test), message="Failure", details=err, expected=first, actual=second, duration=duration
        )

    def addSkip(self, test, reason):
        self.init_suite(test)
        self.current_failed = True
        self.messages.testIgnored(self.getTestName(test), message=reason)

    def _getSuite(self, test):
        try:
            suite = strclass(test.suite)
            suite_location = test.suite.location
            location = test.suite.abs_location
            if hasattr(test, "lineno"):
                location = location + ":" + str(test.lineno)
            else:
                location = location + ":" + str(test.test.lineno)
        except AttributeError:
            import inspect

            try:
                source_file = inspect.getsourcefile(test.__class__)
                if source_file:
                    source_dir_splitted = source_file.split("/")[:-1]
                    source_dir = "/".join(source_dir_splitted) + "/"
                else:
                    source_dir = ""
            except TypeError:
                source_dir = ""

            suite = strclass(test.__class__)
            suite_location = "python_uttestid://" + source_dir + suite
开发者ID:ashanco,项目名称:intellij-community,代码行数:70,代码来源:tcunittest.py

示例3: TeamcityPlugin

# 需要导入模块: from tcmessages import TeamcityServiceMessages [as 别名]
# 或者: from tcmessages.TeamcityServiceMessages import testFailed [as 别名]
class TeamcityPlugin(ErrorClassPlugin, TextTestResult, TeamcityTestResult):
  """
  TeamcityTest plugin for nose tests
  """
  name = "TeamcityPlugin"
  enabled = True

  def __init__(self, stream=sys.stderr, descriptions=None, verbosity=1,
               config=None, errorClasses=None):
    super(TeamcityPlugin, self).__init__()

    if errorClasses is None:
      errorClasses = {}

    self.errorClasses = errorClasses
    if config is None:
      config = Config()
    self.config = config
    self.output = stream
    self.messages = TeamcityServiceMessages(self.output,
      prepend_linebreak=True)
    self.messages.testMatrixEntered()
    self.current_suite = None
    TextTestResult.__init__(self, stream, descriptions, verbosity, config,
      errorClasses)
    TeamcityTestResult.__init__(self, stream)

  def configure(self, options, conf):
    if not self.can_configure:
      return
    self.conf = conf


  def addError(self, test, err):
    exctype, value, tb = err
    err = self.formatErr(err)
    if exctype == SkipTest:
        self.messages.testIgnored(self.getTestName(test), message='Skip')
    else:
        self.messages.testError(self.getTestName(test), message='Error', details=err, duration=self.__getDuration(test))

  def formatErr(self, err):
    exctype, value, tb = err
    if isinstance(value, str):
      try:
        value = exctype(value)
      except TypeError:
        pass
    return ''.join(traceback.format_exception(exctype, value, tb))

  def is_gen(self, test):
    if hasattr(test, "test") and hasattr(test.test, "descriptor"):
      if test.test.descriptor is not None:
        return True
    return False


  def getTestName(self, test):
    if hasattr(test, "error_context"):
      return test.error_context
    test_name_full = str(test)
    if self.is_gen(test):
      return test_name_full

    ind_1 = test_name_full.rfind('(')
    if ind_1 != -1:
      return test_name_full[:ind_1]
    return test_name_full


  def addFailure(self, test, err):
    err = self.formatErr(err)

    self.messages.testFailed(self.getTestName(test),
      message='Failure', details=err)


  def addSkip(self, test, reason):
    self.messages.testIgnored(self.getTestName(test), message=reason)


  def _getSuite(self, test):
    if hasattr(test, "suite"):
      suite = strclass(test.suite)
      suite_location = test.suite.location
      location = test.suite.abs_location
      if hasattr(test, "lineno"):
        location = location + ":" + str(test.lineno)
      else:
        location = location + ":" + str(test.test.lineno)
    else:
      suite = strclass(test.__class__)
      suite_location = "python_nosetestid://" + suite
      try:
        from nose.util import func_lineno

        if hasattr(test.test, "descriptor") and test.test.descriptor:
          suite_location = "file://" + self.test_address(
            test.test.descriptor)
          location = suite_location + ":" + str(
#.........这里部分代码省略.........
开发者ID:influencia0406,项目名称:intellij-community,代码行数:103,代码来源:nose_utils.py

示例4: TeamcityTestResult

# 需要导入模块: from tcmessages import TeamcityServiceMessages [as 别名]
# 或者: from tcmessages.TeamcityServiceMessages import testFailed [as 别名]
class TeamcityTestResult(TestResult):
  def __init__(self, stream=sys.stdout, *args, **kwargs):
    TestResult.__init__(self)
    for arg, value in kwargs.items():
      setattr(self, arg, value)
    self.output = stream
    self.messages = TeamcityServiceMessages(self.output, prepend_linebreak=True)
    self.messages.testMatrixEntered()
    self.current_suite = None

  def find_first(self, val):
    quot = val[0]
    count = 1
    quote_ind = val[count:].find(quot)
    while val[count+quote_ind-1] == "\\" and quote_ind != -1:
      count = count + quote_ind + 1
      quote_ind = val[count:].find(quot)

    return val[0:quote_ind+count+1]

  def find_second(self, val):
    val_index = val.find("!=")
    if val_index != -1:
      count = 1
      val = val[val_index+2:].strip()
      quot = val[0]
      quote_ind = val[count:].find(quot)
      while val[count+quote_ind-1] == "\\" and quote_ind != -1:
        count = count + quote_ind + 1
        quote_ind = val[count:].find(quot)
      return val[0:quote_ind+count+1]

    else:
      quot = val[-1]
      count = 0
      quote_ind = val[:len(val)-count-1].rfind(quot)
      while val[quote_ind-1] == "\\":
        quote_ind = val[:quote_ind-1].rfind(quot)
      return val[quote_ind:]

  def formatErr(self, err):
    exctype, value, tb = err
    return ''.join(traceback.format_exception(exctype, value, tb))

  def getTestName(self, test):
    if hasattr(test, '_testMethodName'):
      if test._testMethodName == "runTest":
        return str(test)
      return test._testMethodName
    else:
      test_name = str(test)
      whitespace_index = test_name.index(" ")
      if whitespace_index != -1:
        test_name = test_name[:whitespace_index]
      return test_name

  def getTestId(self, test):
    return test.id

  def addSuccess(self, test):
    TestResult.addSuccess(self, test)

  def addError(self, test, err):
    TestResult.addError(self, test, err)

    err = self._exc_info_to_string(err, test)

    self.messages.testError(self.getTestName(test),
                            message='Error', details=err)

  def find_error_value(self, err):
    error_value = traceback.extract_tb(err)
    error_value = error_value[-1][-1]
    return error_value.split('assert')[-1].strip()

  def addFailure(self, test, err):
    TestResult.addFailure(self, test, err)

    error_value = smart_str(err[1])
    if not len(error_value):
      # means it's test function and we have to extract value from traceback
      error_value = self.find_error_value(err[2])

    self_find_first = self.find_first(error_value)
    self_find_second = self.find_second(error_value)
    quotes = ["'", '"']
    if (self_find_first[0] == self_find_first[-1] and self_find_first[0] in quotes and
        self_find_second[0] == self_find_second[-1] and self_find_second[0] in quotes):
      # let's unescape strings to show sexy multiline diff in PyCharm.
      # By default all caret return chars are escaped by testing framework
      first = self._unescape(self_find_first)
      second = self._unescape(self_find_second)
    else:
      first = second = ""
    err = self._exc_info_to_string(err, test)

    self.messages.testFailed(self.getTestName(test),
                             message='Failure', details=err, expected=first, actual=second)

  def addSkip(self, test, reason):
#.........这里部分代码省略.........
开发者ID:ixcel4prescott,项目名称:USATodaySports,代码行数:103,代码来源:tcunittest.py


注:本文中的tcmessages.TeamcityServiceMessages.testFailed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。