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

Python compat._b函数代码示例

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

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



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

示例1: skip_quoted_bracket

 def skip_quoted_bracket(self, keyword):
     # This tests it is accepted, but cannot test it is used today, because
     # of not having a way to expose it in Python so far.
     self.protocol.lineReceived(_b("%s mcdonalds farm [\n" % keyword))
     self.protocol.lineReceived(_b(" ]\n"))
     self.protocol.lineReceived(_b("]\n"))
     self.assertSkip(_b("]\n"))
开发者ID:0x90shell,项目名称:pth-toolkit,代码行数:7,代码来源:test_test_protocol.py


示例2: test_calls_list_tests

 def test_calls_list_tests(self):
     ui, cmd = self.get_test_ui_and_cmd(args=('--', 'bar', 'quux'))
     cmd.repository_factory = memory.RepositoryFactory()
     if v2_avail:
         buffer = BytesIO()
         stream = subunit.StreamResultToBytes(buffer)
         stream.status(test_id='returned', test_status='exists')
         stream.status(test_id='values', test_status='exists')
         subunit_bytes = buffer.getvalue()
     else:
         subunit_bytes = _b('returned\n\nvalues\n')
     ui.proc_outputs = [subunit_bytes]
     self.setup_repo(cmd, ui)
     self.set_config(
         '[DEFAULT]\ntest_command=foo $LISTOPT $IDOPTION\n'
         'test_id_option=--load-list $IDFILE\n'
         'test_list_option=--list\n')
     self.assertEqual(0, cmd.execute())
     expected_cmd = 'foo --list  bar quux'
     self.assertEqual([
         ('values', [('running', expected_cmd)]),
         ('popen', (expected_cmd,),
          {'shell': True, 'stdout': PIPE, 'stdin': PIPE}),
         ('communicate',),
         ('stream', _b('returned\nvalues\n')),
         ], ui.outputs)
开发者ID:dstanek,项目名称:testrepository,代码行数:26,代码来源:test_list_tests.py


示例3: xfail_quoted_bracket

 def xfail_quoted_bracket(self, keyword, as_success):
     # This tests it is accepted, but cannot test it is used today, because
     # of not having a way to expose it in Python so far.
     self.protocol.lineReceived(_b("%s mcdonalds farm [\n" % keyword))
     self.protocol.lineReceived(_b(" ]\n"))
     self.protocol.lineReceived(_b("]\n"))
     self.check_success_or_xfail(as_success, "]\n")
开发者ID:0x90shell,项目名称:pth-toolkit,代码行数:7,代码来源:test_test_protocol.py


示例4: test_success_empty_message

 def test_success_empty_message(self):
     self.protocol.lineReceived(_b("success mcdonalds farm [\n"))
     self.protocol.lineReceived(_b("]\n"))
     details = {}
     details['message'] = Content(ContentType("text", "plain"),
         lambda:[_b("")])
     self.assertSuccess(details)
开发者ID:0x90shell,项目名称:pth-toolkit,代码行数:7,代码来源:test_test_protocol.py


示例5: test_failure_empty_message

 def test_failure_empty_message(self):
     self.protocol.lineReceived(_b("failure mcdonalds farm [\n"))
     self.protocol.lineReceived(_b("]\n"))
     details = {}
     details['traceback'] = Content(ContentType("text", "x-traceback",
         {'charset': 'utf8'}), lambda:[_b("")])
     self.assertFailure(details)
开发者ID:0x90shell,项目名称:pth-toolkit,代码行数:7,代码来源:test_test_protocol.py


示例6: _addOutcome

    def _addOutcome(self, outcome, test, error=None, details=None, error_permitted=True):
        """Report a failure in test test.

        Only one of error and details should be provided: conceptually there
        are two separate methods:
            addOutcome(self, test, error)
            addOutcome(self, test, details)

        :param outcome: A string describing the outcome - used as the
            event name in the subunit stream.
        :param error: Standard unittest positional argument form - an
            exc_info tuple.
        :param details: New Testing-in-python drafted API; a dict from string
            to subunit.Content objects.
        :param error_permitted: If True then one and only one of error or
            details must be supplied. If False then error must not be supplied
            and details is still optional.  """
        self._stream.write(_b("%s: " % outcome) + self._test_id(test))
        if error_permitted:
            if error is None and details is None:
                raise ValueError
        else:
            if error is not None:
                raise ValueError
        if error is not None:
            self._stream.write(self._start_simple)
            tb_content = TracebackContent(error, test)
            for bytes in tb_content.iter_bytes():
                self._stream.write(bytes)
        elif details is not None:
            self._write_details(details)
        else:
            self._stream.write(_b("\n"))
        if details is not None or error is not None:
            self._stream.write(self._end_simple)
开发者ID:pvaneck,项目名称:subunit,代码行数:35,代码来源:__init__.py


示例7: __init__

    def __init__(self, output, strict=True):
        """Create a decoder decoding to output.

        :param output: A file-like object. Bytes written to the Decoder are
            decoded to strip off the chunking and written to the output.
            Up to a full write worth of data or a single control line may be
            buffered (whichever is larger). The close method should be called
            when no more data is available, to detect short streams; the
            write method will return none-None when the end of a stream is
            detected. The output object must accept bytes objects.

        :param strict: If True (the default), the decoder will not knowingly
            accept input that is not conformant to the HTTP specification.
            (This does not imply that it will catch every nonconformance.)
            If False, it will accept incorrect input that is still
            unambiguous.
        """
        self.output = output
        self.buffered_bytes = []
        self.state = self._read_length
        self.body_length = 0
        self.strict = strict
        self._match_chars = _b("0123456789abcdefABCDEF\r\n")
        self._slash_n = _b('\n')
        self._slash_r = _b('\r')
        self._slash_rn = _b('\r\n')
        self._slash_nr = _b('\n\r')
开发者ID:AIdrifter,项目名称:samba,代码行数:27,代码来源:chunked.py


示例8: test_long_bytes

 def test_long_bytes(self):
     one_line_b = self._long_b.replace(_b("\n"), _b(" "))
     mismatch = _BinaryMismatch(one_line_b, "!~", self._long_b)
     self.assertEqual(mismatch.describe(),
         "%s:\nreference = %s\nactual    = %s\n" % ("!~",
             text_repr(one_line_b),
             text_repr(self._long_b, multiline=True)))
开发者ID:AlexOreshkevich,项目名称:mongo,代码行数:7,代码来源:test_basic.py


示例9: test_time_accepted_stdlib

 def test_time_accepted_stdlib(self):
     self.result = Python26TestResult()
     self.stream = BytesIO()
     self.protocol = subunit.TestProtocolServer(self.result,
         stream=self.stream)
     self.protocol.lineReceived(_b("time: 2001-12-12 12:59:59Z\n"))
     self.assertEqual(_b(""), self.stream.getvalue())
开发者ID:0x90shell,项目名称:pth-toolkit,代码行数:7,代码来源:test_test_protocol.py


示例10: __init__

    def __init__(self, client, stream=None, forward_stream=None):
        """Create a TestProtocolServer instance.

        :param client: An object meeting the unittest.TestResult protocol.
        :param stream: The stream that lines received which are not part of the
            subunit protocol should be written to. This allows custom handling
            of mixed protocols. By default, sys.stdout will be used for
            convenience. It should accept bytes to its write() method.
        :param forward_stream: A stream to forward subunit lines to. This
            allows a filter to forward the entire stream while still parsing
            and acting on it. By default forward_stream is set to
            DiscardStream() and no forwarding happens.
        """
        self.client = ExtendedToOriginalDecorator(client)
        if stream is None:
            stream = sys.stdout
            if sys.version_info > (3, 0):
                stream = stream.buffer
        self._stream = stream
        self._forward_stream = forward_stream or DiscardStream()
        # state objects we can switch too
        self._in_test = _InTest(self)
        self._outside_test = _OutSideTest(self)
        self._reading_error_details = _ReadingErrorDetails(self)
        self._reading_failure_details = _ReadingFailureDetails(self)
        self._reading_skip_details = _ReadingSkipDetails(self)
        self._reading_success_details = _ReadingSuccessDetails(self)
        self._reading_xfail_details = _ReadingExpectedFailureDetails(self)
        self._reading_uxsuccess_details = _ReadingUnexpectedSuccessDetails(self)
        # start with outside test.
        self._state = self._outside_test
        # Avoid casts on every call
        self._plusminus = _b('+-')
        self._push_sym = _b('push')
        self._pop_sym = _b('pop')
开发者ID:RayFerr000,项目名称:PLTL,代码行数:35,代码来源:__init__.py


示例11: test_from_file

 def test_from_file(self):
     fd, path = tempfile.mkstemp()
     self.addCleanup(os.remove, path)
     os.write(fd, _b("some data"))
     os.close(fd)
     content = content_from_file(path, UTF8_TEXT, chunk_size=2)
     self.assertThat(list(content.iter_bytes()), Equals([_b("so"), _b("me"), _b(" d"), _b("at"), _b("a")]))
开发者ID:0x90shell,项目名称:pth-toolkit,代码行数:7,代码来源:test_content.py


示例12: failure_quoted_bracket

 def failure_quoted_bracket(self, keyword):
     self.protocol.lineReceived(_b("%s mcdonalds farm [\n" % keyword))
     self.protocol.lineReceived(_b(" ]\n"))
     self.protocol.lineReceived(_b("]\n"))
     details = {}
     details['traceback'] = Content(ContentType("text", "x-traceback",
         {'charset': 'utf8'}), lambda:[_b("]\n")])
     self.assertFailure(details)
开发者ID:0x90shell,项目名称:pth-toolkit,代码行数:8,代码来源:test_test_protocol.py


示例13: tags

 def tags(self, new_tags, gone_tags):
     """Inform the client about tags added/removed from the stream."""
     if not new_tags and not gone_tags:
         return
     tags = set([tag.encode('utf8') for tag in new_tags])
     tags.update([_b("-") + tag.encode('utf8') for tag in gone_tags])
     tag_line = _b("tags: ") + _b(" ").join(tags) + _b("\n")
     self._stream.write(tag_line)
开发者ID:RayFerr000,项目名称:PLTL,代码行数:8,代码来源:__init__.py


示例14: test_decode_newline_nonstrict

 def test_decode_newline_nonstrict(self):
     """Tolerate chunk markers with no CR character."""
     # From <http://pad.lv/505078>
     self.decoder = subunit.chunked.Decoder(self.output, strict=False)
     self.assertEqual(None, self.decoder.write(_b('a\n')))
     self.assertEqual(None, self.decoder.write(_b('abcdeabcde')))
     self.assertEqual(_b(''), self.decoder.write(_b('0\n')))
     self.assertEqual(_b('abcdeabcde'), self.output.getvalue())
开发者ID:AlexOreshkevich,项目名称:mongo,代码行数:8,代码来源:test_chunked.py


示例15: addSkip

 def addSkip(self, test, reason=None, details=None):
     """Report a skipped test."""
     if reason is None:
         self._addOutcome("skip", test, error=None, details=details)
     else:
         self._stream.write(_b("skip: %s [\n" % test.id()))
         self._stream.write(_b("%s\n" % reason))
         self._stream.write(self._end_simple)
开发者ID:RayFerr000,项目名称:PLTL,代码行数:8,代码来源:__init__.py


示例16: test_from_file_with_whence_seek

 def test_from_file_with_whence_seek(self):
     f = tempfile.NamedTemporaryFile()
     f.write(_b('some data'))
     f.flush()
     self.addCleanup(f.close)
     content = content_from_file(
         f.name, UTF8_TEXT, chunk_size=50, seek_offset=-4, seek_whence=2)
     self.assertThat(
         list(content.iter_bytes()), Equals([_b('data')]))
开发者ID:ClusterHQ,项目名称:testtools,代码行数:9,代码来源:test_content.py


示例17: test_keywords_after_failure

 def test_keywords_after_failure(self):
     self.protocol.lineReceived(_b("test old mcdonald\n"))
     self.protocol.lineReceived(_b("failure old mcdonald\n"))
     self.keywords_before_test()
     self.assertEqual(self.client._events, [
         ('startTest', self.test),
         ('addFailure', self.test, {}),
         ('stopTest', self.test),
         ])
开发者ID:0x90shell,项目名称:pth-toolkit,代码行数:9,代码来源:test_test_protocol.py


示例18: test_progress_accepted_stdlib

 def test_progress_accepted_stdlib(self):
     self.result = Python26TestResult()
     self.stream = BytesIO()
     self.protocol = subunit.TestProtocolServer(self.result,
         stream=self.stream)
     self.protocol.lineReceived(_b("progress: 23"))
     self.protocol.lineReceived(_b("progress: -2"))
     self.protocol.lineReceived(_b("progress: +4"))
     self.assertEqual(_b(""), self.stream.getvalue())
开发者ID:0x90shell,项目名称:pth-toolkit,代码行数:9,代码来源:test_test_protocol.py


示例19: test_keywords_after_success

 def test_keywords_after_success(self):
     self.protocol.lineReceived(_b("test old mcdonald\n"))
     self.protocol.lineReceived(_b("success old mcdonald\n"))
     self.keywords_before_test()
     self.assertEqual([
         ('startTest', self.test),
         ('addSuccess', self.test),
         ('stopTest', self.test),
         ], self.client._events)
开发者ID:0x90shell,项目名称:pth-toolkit,代码行数:9,代码来源:test_test_protocol.py


示例20: test_lost_connected_after_failure

 def test_lost_connected_after_failure(self):
     self.protocol.lineReceived(_b("test old mcdonald\n"))
     self.protocol.lineReceived(_b("failure old mcdonald\n"))
     self.protocol.lostConnection()
     self.assertEqual([
         ('startTest', self.test),
         ('addFailure', self.test, subunit.RemoteError(_u(""))),
         ('stopTest', self.test),
         ], self.client._events)
开发者ID:0x90shell,项目名称:pth-toolkit,代码行数:9,代码来源:test_test_protocol.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python compat._u函数代码示例发布时间:2022-05-27
下一篇:
Python assertions.assert_that函数代码示例发布时间: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