Beispiel #1
0
 def __init__(self, base_dir):
     """
     :type base_dir str
     :param base_dir base directory of your project
     """
     super(BddRunner, self).__init__()
     self.tc_messages = tcmessages.TeamcityServiceMessages()
     """
     tcmessages TeamCity/Intellij test API. See TeamcityServiceMessages
     """
     self.__base_dir = base_dir
     self.__last_test_start_time = None  # TODO: Doc when use
     self.__last_test_name = None
    # New version supports 1.2.6 only
    use_old_runner = "PYCHARM_BEHAVE_OLD_RUNNER" in os.environ
    from behave.formatter import _registry

    FORMAT_NAME = "com.jetbrains.pycharm.formatter"
    if use_old_runner:

        class _Null(Formatter):
            """
            Null formater to prevent stdout output
            """
            pass

        _registry.register_as(FORMAT_NAME, _Null)
    else:
        custom_messages = tcmessages.TeamcityServiceMessages()
        # Not safe to import it in old mode
        from teamcity.jb_behave_formatter import TeamcityFormatter

        class TeamcityFormatterWithLocation(TeamcityFormatter):
            def _report_suite_started(self, suite, suite_name):
                location = suite.location
                custom_messages.testSuiteStarted(
                    suite_name,
                    _bdd_utils.get_location(base_dir, location.filename,
                                            location.line))

            def _report_test_started(self, test, test_name):
                location = test.location
                custom_messages.testStarted(
                    test_name,