• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python termstyle.bold函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中termstyle.bold函数的典型用法代码示例。如果您正苦于以下问题:Python bold函数的具体用法?Python bold怎么用?Python bold使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_path_stripping_in_test_failure_last_line

    def test_path_stripping_in_test_failure_last_line(self):
        f = io.StringIO()
        r = TerminalReporter(watch_path='/path/to/watch',
                             build_path='/path/to/build',
                             terminal=Terminal(stream=f))

        failures = [[
                        'core.ok',
                        [
                            '/path/to/watch/test/test_core.cc:12: Failure',
                            'Value of: 2',
                            'Expected: ok()',
                            'Which is: 42',
                        ], [], FAILED
                    ]]
        r.report_failures(failures)
        expected = [
            '================================== FAILURES ==================================', # noqa
            termstyle.bold(termstyle.red(
            '__________________________________ core.ok ___________________________________' # noqa
            )),
            '/path/to/watch/test/test_core.cc:12: Failure',
            'Value of: 2',
            'Expected: ok()',
            'Which is: 42',
            termstyle.bold(termstyle.red(
            '____________________________ test/test_core.cc:12 ____________________________', # noqa
            )),
            ]
        actual = f.getvalue().splitlines()
        assert actual == expected
开发者ID:yerejm,项目名称:ttt,代码行数:31,代码来源:test_reporter.py


示例2: desc

			def desc(color):
				desc = color("    %s %s" % (prefix, name))
				if a:
					desc += ' ' + color(termstyle.bold(' '.join(map(nice_repr,a))))
				if kw:
					desc += ' ' + ' '.join([color("%s=%s") % (k, termstyle.bold(repr(v))) for k,v in kw.items()])
				return desc
开发者ID:dobcey,项目名称:pea,代码行数:7,代码来源:formatter.py


示例3: test_report_multiple_failed

    def test_report_multiple_failed(self):
        f = io.StringIO()
        r = TerminalReporter(watch_path='/path',
                             build_path=None,
                             terminal=Terminal(stream=f))

        results = {
                'total_runtime': 2.09,
                'total_passed': 0,
                'total_failed': 2,
                'failures': [
                    [
                        'fail1',
                        [
                             '/path/to/file:12: blah',
                             'results line 2',
                             'results line 3',
                             'results line 4',
                        ], [], FAILED
                    ],
                    [
                        'fail2',
                        [
                             '/path/to/file:102: blah',
                             'results line 2',
                             'results line 3',
                             'results line 4',
                        ], [], FAILED
                    ],
                ]
            }
        r.report_results(results)
        expected = [
            '================================== FAILURES ==================================', # noqa
            termstyle.bold(termstyle.red(
            '___________________________________ fail1 ____________________________________' # noqa
            )),
            '/path/to/file:12: blah',
            'results line 2',
            'results line 3',
            'results line 4',
            termstyle.bold(termstyle.red(
            '_________________________________ to/file:12 _________________________________' # noqa
            )),
            termstyle.bold(termstyle.red(
            '___________________________________ fail2 ____________________________________' # noqa
            )),
            '/path/to/file:102: blah',
            'results line 2',
            'results line 3',
            'results line 4',
            termstyle.bold(termstyle.red(
            '________________________________ to/file:102 _________________________________' # noqa
            )),
            termstyle.bold(termstyle.red(
            '===================== 2 failed, 0 passed in 2.09 seconds =====================' # noqa
            )),
            ]
        actual = f.getvalue().splitlines()
        assert actual == expected
开发者ID:yerejm,项目名称:ttt,代码行数:60,代码来源:test_reporter.py


示例4: main

def main():
    """Module body."""
    parser = OptionParser()
    parser.add_option('-e', '--exec', action='store_true', dest='execute', default=False, help='Command is executed')
    (options, args) = parser.parse_args()
    if len(args) != 1 :
        print "{0}: {1}".format(bold('Syntax'), r'./try_command.py command_identifier?param1=value1\&param2=value2')
        sys.exit(1)
    command_id, command_params = CommandFactory.parse_url(args[0])
    conf_loader = ConfLoader(dirname(realpath(__file__)) + '/conf')
    factory = CommandFactory(conf_loader.load('commands'))
    try:
        command = factory.get_by_id(command_id)
        command.insuflate(command_params) 
    except RxcCommandException as err:
        print '{0}: {1}'.format(bold('Error'), err)
        sys.exit(1)
    
    if not options.execute:
        print "{0}: {1}\n(use --exec to execute it.)".format(bold('Command'), command.to_exec)
        sys.exit(0)
    try:
        result = command.run()
        for key, value in result.items():
            print '-' * 80 
            print "{0}\n{1}".format(bold(key), value)
        print '-' * 80
        sys.exit(0)
    except RxcCommandException as err:
        print '{0}: {1}'.format(bold('Error'), err)
        sys.exit(1)
开发者ID:setsuna-,项目名称:restexecd,代码行数:31,代码来源:try_command.py


示例5: test_writeln_decorator

    def test_writeln_decorator(self):
        f = io.StringIO()
        t = Terminal(stream=f)
        t.writeln('hello', decorator=[bold])
        assert f.getvalue() == bold('hello') + linesep

        f = io.StringIO()
        t = Terminal(stream=f)
        t.writeln('hello', decorator=[bold, red])
        assert f.getvalue() == red(bold('hello')) + linesep
开发者ID:yerejm,项目名称:ttt,代码行数:10,代码来源:test_terminal.py


示例6: test_detailed_verbosity

    def test_detailed_verbosity(self):
        results = [
                'Running main() from gtest_main.cc',
                'Note: Google Test filter = core.ok',
                '[==========] Running 1 test from 1 test case.',
                '[----------] Global test environment set-up.',
                '[----------] 1 test from core',
                '[ RUN      ] core.ok',
                '[       OK ] core.ok (0 ms)',
                '[----------] 1 test from core (0 ms total)',
                '',
                '[----------] Global test environment tear-down',
                '[==========] 1 test from 1 test case ran. (0 ms total)',
                '[  PASSED  ] 1 test.',
                ]
        f = io.StringIO()
        gtest = GTest('/test/test_core.cc', 'test_core',
                      term=Terminal(f, verbosity=1))
        for line in results:
            gtest(sys.stdout, line)

        import termstyle
        expected_results = results[:2]
        for l in results[2:]:
            if l.startswith('['):
                expected_results.append('{}{}'.format(
                    termstyle.green(termstyle.bold(l[:13])),
                    l[13:]
                ))
            else:
                expected_results.append(l)
        assert f.getvalue() == os.linesep.join(expected_results) + os.linesep
开发者ID:yerejm,项目名称:ttt,代码行数:32,代码来源:test_gtest.py


示例7: begin_new_run

	def begin_new_run(self, current_time):
		print "\n" * 10
		subprocess.call('clear')
		msg = "# Running tests at %s  " % (time.strftime("%H:%M:%S", current_time))

		print >> sys.stderr, termstyle.inverted(termstyle.bold(msg))
		print >> sys.stderr, ""
开发者ID:antlong,项目名称:autonose,代码行数:7,代码来源:basic.py


示例8: test_report_with_stdout_and_stderr_in_additional_output

    def test_report_with_stdout_and_stderr_in_additional_output(self):
        f = io.StringIO()
        r = TerminalReporter(watch_path='/path',
                             build_path=None,
                             terminal=Terminal(stream=f))

        results = {
                'total_runtime': 2.09,
                'total_passed': 0,
                'total_failed': 1,
                'failures': [
                    [
                        'fail1',
                        [
                            'extra line 1',
                            'extra line 2',
                            '/path/to/file:12: blah',
                            'results line 1',
                            'results line 2',
                            'results line 3',
                        ], [], FAILED
                    ],
                ]
            }
        r.report_results(results)
        expected = [
            '================================== FAILURES ==================================', # noqa
            termstyle.bold(termstyle.red(
            '___________________________________ fail1 ____________________________________' # noqa
            )),
            '/path/to/file:12: blah',
            'results line 1',
            'results line 2',
            'results line 3',
            '----------------------------- Additional output ------------------------------', # noqa
            'extra line 1',
            'extra line 2',
            termstyle.bold(termstyle.red(
            '_________________________________ to/file:12 _________________________________' # noqa
            )),
            termstyle.bold(termstyle.red(
            '===================== 1 failed, 0 passed in 2.09 seconds =====================' # noqa
            )),
            ]
        actual = f.getvalue().splitlines()
        assert actual == expected
开发者ID:yerejm,项目名称:ttt,代码行数:46,代码来源:test_reporter.py


示例9: process

	def process(self, event):
		if isinstance(event, TestRun):
			print "\n" * 10
			subprocess.call('clear')
			msg = "# Running tests at %s  " % (time.strftime("%H:%M:%S"),)
	
			print >> sys.stderr, termstyle.inverted(termstyle.bold(msg))
			print >> sys.stderr, ""
开发者ID:lieryan,项目名称:autonose,代码行数:8,代码来源:basic.py


示例10: test_report_build_path

    def test_report_build_path(self):
        f = io.StringIO()
        r = TerminalReporter(watch_path='watch_path',
                             build_path='build_path',
                             terminal=Terminal(stream=f))

        r.report_build_path()
        assert f.getvalue() == (termstyle.bold('### Building:   build_path')
                                + os.linesep)
开发者ID:yerejm,项目名称:ttt,代码行数:9,代码来源:test_reporter.py


示例11: test_wait_change

    def test_wait_change(self):
        f = io.StringIO()
        r = TerminalReporter(watch_path='watch_path',
                             build_path='build_path',
                             terminal=Terminal(stream=f),
                             timestamp=lambda: 'timestamp')

        r.wait_change()
        assert f.getvalue() == termstyle.bold(
                    ''.ljust(28, '#') +
                    ' waiting for changes ' +
                    ''.ljust(29, '#')
                ) + os.linesep + termstyle.bold(
                    '### Since:      timestamp'
                ) + os.linesep + termstyle.bold(
                    '### Watching:   watch_path'
                ) + os.linesep + termstyle.bold(
                    '### Build at:   build_path'
                ) + os.linesep
开发者ID:yerejm,项目名称:ttt,代码行数:19,代码来源:test_reporter.py


示例12: test_session_start

    def test_session_start(self):
        f = io.StringIO()
        r = TerminalReporter(watch_path=None,
                             build_path=None,
                             terminal=Terminal(stream=f))

        r.session_start('test')
        assert f.getvalue() == (termstyle.bold(''.ljust(28, '=')
                                               + ' test session starts '
                                               + ''.ljust(29, '='))
                                + os.linesep)
开发者ID:yerejm,项目名称:ttt,代码行数:11,代码来源:test_reporter.py


示例13: __init__

 def __init__(self, termcolor=None):
     """
     termcolor - If None, attempt to autodetect whether we are in a terminal
         and turn on terminal colors if we think we are.  If True, force
         terminal colors on.  If False, force terminal colors off.
     """
     if termcolor is None:
         termstyle.auto()
         self.termcolor = bool(termstyle.bold(""))
     else:
         self.termcolor = termcolor
     self._restoreColor()
开发者ID:MinchinWeb,项目名称:green,代码行数:12,代码来源:output.py


示例14: _relative_path

	def _relative_path(self, path):
		"""
		If path is a child of the current working directory, the relative
		path is returned surrounded by bold xterm escape sequences.
		If path is not a child of the working directory, path is returned
		"""
		try:
			here = os.path.abspath(os.path.realpath(os.getcwd()))
			fullpath = os.path.abspath(os.path.realpath(path))
		except OSError:
			return path
		if fullpath.startswith(here):
			return termstyle.bold(fullpath[len(here)+1:])
		return path
开发者ID:gdyuldin,项目名称:rednose,代码行数:14,代码来源:rednose.py


示例15: _format_exception_message

    def _format_exception_message(self, exception_type, exception_instance, message_color):
        """Returns a colorized formatted exception message."""
        orig_message_lines = to_unicode(exception_instance).splitlines()

        if len(orig_message_lines) == 0:
            return ''
        exception_message = orig_message_lines[0]

        message_lines = [message_color('   ', termstyle.bold(message_color(exception_type.__name__)), ": ") + message_color(exception_message)]
        for line in orig_message_lines[1:]:
            match = re.match('^---.* begin captured stdout.*----$', line)
            if match:
                message_color = termstyle.magenta
                message_lines.append('')
            line = '   ' + line
            message_lines.append(message_color(line))
        return '\n'.join(message_lines)
开发者ID:RyanLadley,项目名称:the_lounge,代码行数:17,代码来源:rednose.py


示例16: _report_test

	def _report_test(self, report_num, type_, test, err):
		"""report the results of a single (failing or errored) test"""
		self._line(termstyle.black)
		self._out("%s) " % (report_num))
		if type_ == failure:
			color = termstyle.red
			self._outln(color('FAIL: %s' % (self._format_test_name(test),)))
		else:
			color = termstyle.yellow
			self._outln(color('ERROR: %s' % (self._format_test_name(test),)))

		exc_type, exc_instance, exc_trace = err

		self._outln()
		self._outln(self._fmt_traceback(exc_trace))
		self._out(color('   ', termstyle.bold(color(exc_type.__name__)), ": "))
		self._outln(self._fmt_message(exc_instance, color))
		self._outln()
开发者ID:gdyuldin,项目名称:rednose,代码行数:18,代码来源:rednose.py


示例17: test_report_all_passed

    def test_report_all_passed(self):
        f = io.StringIO()
        r = TerminalReporter(watch_path=None,
                             build_path=None,
                             terminal=Terminal(stream=f))

        results = {
                'total_runtime': 2.09,
                'total_passed': 1,
                'total_failed': 0,
                'failures': []
                }
        r.report_results(results)
        assert f.getvalue() == (
            termstyle.bold(termstyle.green(''.ljust(26, '=')
                           + ' 1 passed in 2.09 seconds '
                           + ''.ljust(26, '=')))
            + os.linesep)
开发者ID:yerejm,项目名称:ttt,代码行数:18,代码来源:test_reporter.py


示例18: __init__

    def __init__(self, termcolor=None, html=False):
        """
        termcolor - If None, attempt to autodetect whether we are in a terminal
            and turn on terminal colors if we think we are.  If True, force
            terminal colors on.  If False, force terminal colors off.  This
            value is ignored if html is True.

        html - If true, enables HTML output and causes termcolor to be ignored.
        """
        self.html = html
        if html:
            termcolor = False

        if termcolor == None:
            termstyle.auto()
            self.termcolor = bool(termstyle.bold(""))
        else:
            self.termcolor = termcolor
        self._restoreColor()
开发者ID:eavilesmejia,项目名称:green,代码行数:19,代码来源:output.py


示例19: _format_traceback_line

    def _format_traceback_line(self, tb):
        """
        Formats the file / lineno / function line of a traceback element.

        Returns None is the line is not relevent to the user i.e. inside the test runner.
        """
        if self._is_relevant_tb_level(tb):
            return None

        f = tb.tb_frame
        filename = f.f_code.co_filename
        lineno = tb.tb_lineno
        linecache.checkcache(filename)
        function_name = f.f_code.co_name

        line_contents = linecache.getline(filename, lineno, f.f_globals).strip()

        return "    %s line %s in %s\n      %s" % (
            termstyle.blue(self._relative_path(filename) if self.use_relative_path else filename),
            termstyle.bold(termstyle.cyan(lineno)),
            termstyle.cyan(function_name),
            line_contents
        )
开发者ID:RyanLadley,项目名称:the_lounge,代码行数:23,代码来源:rednose.py


示例20: _file_line

	def _file_line(self, tb):
		"""formats the file / lineno / function line of a traceback element"""
		prefix = "file://"
		prefix = ""

		f = tb.tb_frame
		if '__unittest' in f.f_globals:
			# this is the magical flag that prevents unittest internal
			# code from junking up the stacktrace
			return None

		filename = f.f_code.co_filename
		lineno = tb.tb_lineno
		linecache.checkcache(filename)
		function_name = f.f_code.co_name

		line_contents = linecache.getline(filename, lineno, f.f_globals).strip()

		return "    %s line %s in %s\n      %s" % (
			termstyle.blue(prefix, self._relative_path(filename)),
			termstyle.bold(termstyle.cyan(lineno)),
			termstyle.cyan(function_name),
			line_contents)
开发者ID:gdyuldin,项目名称:rednose,代码行数:23,代码来源:rednose.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python termstyle.green函数代码示例发布时间:2022-05-27
下一篇:
Python i18n._函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap