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


Python termstyle.bold函数代码示例

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


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


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