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

Python compat._u函数代码示例

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

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



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

示例1: check_success_or_xfail

 def check_success_or_xfail(self, as_success, error_message=None):
     if as_success:
         self.assertEqual([
             ('startTest', self.test),
             ('addSuccess', self.test),
             ('stopTest', self.test),
             ], self.client._events)
     else:
         details = {}
         if error_message is not None:
             details['traceback'] = Content(
                 ContentType("text", "x-traceback", {'charset': 'utf8'}),
                 lambda:[_b(error_message)])
         if isinstance(self.client, ExtendedTestResult):
             value = details
         else:
             if error_message is not None:
                 value = subunit.RemoteError(_u("Text attachment: traceback\n"
                     "------------\n") + _u(error_message) +
                     _u("------------\n"))
             else:
                 value = subunit.RemoteError()
         self.assertEqual([
             ('startTest', self.test),
             ('addExpectedFailure', self.test, value),
             ('stopTest', self.test),
             ], self.client._events)
开发者ID:0x90shell,项目名称:pth-toolkit,代码行数:27,代码来源:test_test_protocol.py


示例2: test_describe_non_ascii_unicode

 def test_describe_non_ascii_unicode(self):
     string = _u("A\xA7")
     suffix = _u("B\xA7")
     mismatch = DoesNotEndWith(string, suffix)
     self.assertEqual("%s does not end with %s." % (
         text_repr(string), text_repr(suffix)),
         mismatch.describe())
开发者ID:AlexOreshkevich,项目名称:mongo,代码行数:7,代码来源:test_basic.py


示例3: test_four_tests_in_a_row_with_plan

 def test_four_tests_in_a_row_with_plan(self):
     # A file
     # 1..4
     # ok 1 - first test in a script with no plan at all
     # not ok 2 - second
     # ok 3 - third
     # not ok 4 - fourth
     # results in four tests numbered and named
     self.tap.write(_u('1..4\n'))
     self.tap.write(_u('ok 1 - first test in a script with a plan\n'))
     self.tap.write(_u('not ok 2 - second\n'))
     self.tap.write(_u('ok 3 - third\n'))
     self.tap.write(_u('not ok 4 - fourth\n'))
     self.tap.seek(0)
     result = subunit.TAP2SubUnit(self.tap, self.subunit)
     self.assertEqual(0, result)
     self.check_events([
         ('status', 'test 1 - first test in a script with a plan',
          'success', None, False, None, None, True, None, None, None),
         ('status', 'test 2 - second', 'fail', None, False, None, None,
          True, None, None, None),
         ('status', 'test 3 - third', 'success', None, False, None, None,
          True, None, None, None),
         ('status', 'test 4 - fourth', 'fail', None, False, None, None,
          True, None, None, None)])
开发者ID:AlexOreshkevich,项目名称:mongo,代码行数:25,代码来源:test_tap2subunit.py


示例4: test_eq

 def test_eq(self):
     error = subunit.RemoteError(_u("Something went wrong"))
     another_error = subunit.RemoteError(_u("Something went wrong"))
     different_error = subunit.RemoteError(_u("boo!"))
     self.assertEqual(error, another_error)
     self.assertNotEqual(error, different_error)
     self.assertNotEqual(different_error, another_error)
开发者ID:0x90shell,项目名称:pth-toolkit,代码行数:7,代码来源:test_test_protocol.py


示例5: test_supports_syntax_error

 def test_supports_syntax_error(self):
     self._assert_exception_format(
         SyntaxError,
         SyntaxError("Some Syntax Message", ("/path/to/file", 12, 2, "This is the line of code")),
         [
             _u('  File "/path/to/file", line 12\n'),
             _u("    This is the line of code\n"),
             _u("     ^\n"),
             _u("SyntaxError: Some Syntax Message\n"),
         ],
     )
开发者ID:ChineseDr,项目名称:mongo,代码行数:11,代码来源:test_compat.py


示例6: test_individual_functions_called

 def test_individual_functions_called(self):
     self.patch(testtools.compat, "_format_stack_list", lambda stack_list: [_u("format stack list called\n")])
     self.patch(
         testtools.compat, "_format_exception_only", lambda etype, evalue: [_u("format exception only called\n")]
     )
     result = _format_exc_info(None, None, None)
     expected = [
         _u("Traceback (most recent call last):\n"),
         _u("format stack list called\n"),
         _u("format exception only called\n"),
     ]
     self.assertThat(expected, Equals(result))
开发者ID:ChineseDr,项目名称:mongo,代码行数:12,代码来源:test_compat.py


示例7: test_assertThat_verbose_unicode

 def test_assertThat_verbose_unicode(self):
     # When assertThat is given matchees or matchers that contain non-ASCII
     # unicode strings, we can still provide a meaningful error.
     matchee = _u("\xa7")
     matcher = Equals(_u("a"))
     expected = (
         "Match failed. Matchee: %s\n"
         "Matcher: %s\n"
         "Difference: %s\n\n" % (repr(matchee).replace("\\xa7", matchee), matcher, matcher.match(matchee).describe())
     )
     e = self.assertRaises(self.failureException, self.assertThat, matchee, matcher, verbose=True)
     self.assertEqual(expected, self.get_error_string(e))
开发者ID:kampka,项目名称:testtools,代码行数:12,代码来源:test_testcase.py


示例8: _format_error

 def _format_error(self, label, test, error_text, test_tags=None):
     test_tags = test_tags or ()
     tags = _u(' ').join(test_tags)
     if tags:
         tags = _u('tags: %s\n') % tags
     return _u('').join([
         self.sep1,
         _u('%s: %s\n') % (label, test.id()),
         tags,
         self.sep2,
         error_text,
         ])
开发者ID:testing-cabal,项目名称:testrepository,代码行数:12,代码来源:cli.py


示例9: test_syntax_error_line_utf_8

 def test_syntax_error_line_utf_8(self):
     """Syntax error on a utf-8 line shows the line decoded"""
     text, raw = self._get_sample_text("utf-8")
     textoutput = self._setup_external_case("import bad")
     self._write_module("bad", "utf-8", _u("\ufeff^ = 0 # %s\n") % text)
     textoutput = self._run_external_case()
     self.assertIn(self._as_output(_u(
         'bad.py", line 1\n'
         '    ^ = 0 # %s\n'
         + ' ' * self._error_on_character +
         '   ^\n'
         'SyntaxError: ') %
         text), textoutput)
开发者ID:Alexandr-Galko,项目名称:samba,代码行数:13,代码来源:test_testresult.py


示例10: __init__

 def __init__(self, ui, get_id, stream, previous_run=None, filter_tags=None):
     """Construct a CLITestResult writing to stream.
     
     :param filter_tags: Tags that should be used to filter tests out. When
         a tag in this set is present on a test outcome, the test is not
         counted towards the test run count. If the test errors, then it is
         still counted and the error is still shown.
     """
     super(CLITestResult, self).__init__(ui, get_id, previous_run)
     self.stream = unicode_output_stream(stream)
     self.sep1 = _u('=' * 70 + '\n')
     self.sep2 = _u('-' * 70 + '\n')
     self.filter_tags = filter_tags or frozenset()
     self.filterable_states = set(['success', 'uxsuccess', 'xfail', 'skip'])
开发者ID:testing-cabal,项目名称:testrepository,代码行数:14,代码来源:cli.py


示例11: test_bail_out_errors

 def test_bail_out_errors(self):
     # A file with line in it
     # Bail out! COMMENT
     # is treated as an error
     self.tap.write(_u("ok 1 foo\n"))
     self.tap.write(_u("Bail out! Lifejacket engaged\n"))
     self.tap.seek(0)
     result = subunit.TAP2SubUnit(self.tap, self.subunit)
     self.assertEqual(0, result)
     self.check_events([
         ('status', 'test 1 foo', 'success', None, False, None, None, True,
          None, None, None),
         ('status', 'Bail out! Lifejacket engaged', 'fail', None, False,
          None, None, True, None, None, None)])
开发者ID:AlexOreshkevich,项目名称:mongo,代码行数:14,代码来源:test_tap2subunit.py


示例12: __init__

 def __init__(self, parser):
     self.parser = parser
     self._test_sym = (_b("test"), _b("testing"))
     self._colon_sym = _b(":")
     self._error_sym = (_b("error"),)
     self._failure_sym = (_b("failure"),)
     self._progress_sym = (_b("progress"),)
     self._skip_sym = _b("skip")
     self._success_sym = (_b("success"), _b("successful"))
     self._tags_sym = (_b("tags"),)
     self._time_sym = (_b("time"),)
     self._xfail_sym = (_b("xfail"),)
     self._uxsuccess_sym = (_b("uxsuccess"),)
     self._start_simple = _u(" [")
     self._start_multipart = _u(" [ multipart")
开发者ID:pvaneck,项目名称:subunit,代码行数:15,代码来源:__init__.py


示例13: test_stream_content_reset

 def test_stream_content_reset(self):
     detail_name = 'test'
     fixture = StringStream(detail_name)
     with fixture:
         stream = fixture.stream
         content = fixture.getDetails()[detail_name]
         stream.write(_u("testing 1 2 3"))
     with fixture:
         # The old content object returns the old usage
         self.assertEqual(_u("testing 1 2 3"), content.as_text())
         content = fixture.getDetails()[detail_name]
         # A new fixture returns the new output:
         stream = fixture.stream
         stream.write(_u("1 2 3 testing"))
         self.assertEqual(_u("1 2 3 testing"), content.as_text())
开发者ID:SvenDowideit,项目名称:clearlinux,代码行数:15,代码来源:test_streams.py


示例14: _handleTime

 def _handleTime(self, offset, line):
     # Accept it, but do not do anything with it yet.
     try:
         event_time = iso8601.parse_date(line[offset:-1])
     except TypeError:
         raise TypeError(_u("Failed to parse %r, got %r") % (line, sys.exec_info[1]))
     self.client.time(event_time)
开发者ID:pvaneck,项目名称:subunit,代码行数:7,代码来源:__init__.py


示例15: test_useFixture_details_captured

    def test_useFixture_details_captured(self):
        class DetailsFixture(fixtures.Fixture):
            def setUp(self):
                fixtures.Fixture.setUp(self)
                self.addCleanup(delattr, self, "content")
                self.content = [_b("content available until cleanUp")]
                self.addDetail("content", content.Content(content_type.UTF8_TEXT, self.get_content))

            def get_content(self):
                return self.content

        fixture = DetailsFixture()

        class SimpleTest(TestCase):
            def test_foo(self):
                self.useFixture(fixture)
                # Add a colliding detail (both should show up)
                self.addDetail("content", content.Content(content_type.UTF8_TEXT, lambda: [_b("foo")]))

        result = ExtendedTestResult()
        SimpleTest("test_foo").run(result)
        self.assertEqual("addSuccess", result._events[-2][0])
        details = result._events[-2][2]
        self.assertEqual(["content", "content-1"], sorted(details.keys()))
        self.assertEqual("foo", _u("").join(details["content"].iter_text()))
        self.assertEqual("content available until cleanUp", "".join(details["content-1"].iter_text()))
开发者ID:0x90shell,项目名称:pth-toolkit,代码行数:26,代码来源:test_fixturesupport.py


示例16: test_supports_strange_syntax_error

 def test_supports_strange_syntax_error(self):
     """Test support for syntax errors with unusual number of arguments"""
     self._assert_exception_format(
         SyntaxError,
         SyntaxError("Message"),
         [_u("SyntaxError: Message\n")]
     )
开发者ID:bz2,项目名称:testtools,代码行数:7,代码来源:test_compat.py


示例17: _format_summary

 def _format_summary(self, successful, tests, tests_delta,
                     time, time_delta, values):
     # We build the string by appending to a list of strings and then
     # joining trivially at the end. Avoids expensive string concatenation.
     summary = []
     a = summary.append
     if tests:
         a("Ran %s" % (tests,))
         if tests_delta:
             a(" (%+d)" % (tests_delta,))
         a(" tests")
     if time:
         if not summary:
             a("Ran tests")
         a(" in %0.3fs" % (time,))
         if time_delta:
             a(" (%+0.3fs)" % (time_delta,))
     if summary:
         a("\n")
     if successful:
         a('PASSED')
     else:
         a('FAILED')
     if values:
         a(' (')
         values_strings = []
         for name, value, delta in values:
             value_str = '%s=%s' % (name, value)
             if delta:
                 value_str += ' (%+d)' % (delta,)
             values_strings.append(value_str)
         a(', '.join(values_strings))
         a(')')
     return _u('').join(summary)
开发者ID:testing-cabal,项目名称:testrepository,代码行数:34,代码来源:cli.py


示例18: test_addSkip_is_success

 def test_addSkip_is_success(self):
     # addSkip does not fail the test run.
     result = self.makeResult()
     result.startTest(self)
     result.addSkip(self, _u("Skipped for some reason"))
     result.stopTest(self)
     self.assertTrue(result.wasSuccessful())
开发者ID:Alexandr-Galko,项目名称:samba,代码行数:7,代码来源:test_testresult.py


示例19: _got_failure

 def _got_failure(deferred, failure):
     deferred.addErrback(lambda _: None)
     return Mismatch(
         _u('Success result expected on %r, found failure result '
            'instead: %r' % (deferred, failure)),
         {'traceback': failure_content(failure)},
     )
开发者ID:bigjools,项目名称:testtools,代码行数:7,代码来源:_matchers.py


示例20: as_text

    def as_text(self):
        """Return all of the content as text.

        This is only valid where ``iter_text`` is.  It will load all of the
        content into memory.  Where this is a concern, use ``iter_text``
        instead.
        """
        return _u('').join(self.iter_text())
开发者ID:jogo,项目名称:testtools,代码行数:8,代码来源:content.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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