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


Python compat._b函数代码示例

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


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


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