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

Python six.assertRegex函数代码示例

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

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



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

示例1: test_source_methods_with_full_model

    def test_source_methods_with_full_model(self):
        from sherpa.utils.err import IdentifierErr

        ui.load_data('full', self.ascii)
        ui.set_full_model('full', 'powlaw1d.p1')

        # Test Case 1
        try:
            ui.get_source('full')
        except IdentifierErr as e:
            six.assertRegex(self, str(e),
                                     "Convolved model\n.*\n is set for dataset full. You should use get_model instead.",
                                     str(e))
        try:
            ui.plot_source('full')
        except IdentifierErr as e:
            six.assertRegex(self, str(e),
                                     "Convolved model\n.*\n is set for dataset full. You should use plot_model instead.",
                                     str(e))

        # Test Case 2
        ui.set_source('full', 'powlaw1d.p2')
        ui.get_source('full')

        # Test Case 3
        ui.load_data('not_full', self.ascii)
        try:
            ui.get_source('not_full')
        except IdentifierErr as e:
            self.assertEqual('source not_full has not been set, consider using set_source() or set_model()', str(e))
开发者ID:DougBurke,项目名称:sherpa,代码行数:30,代码来源:test_ui.py


示例2: test_list_ipblocks

    def test_list_ipblocks(self):
        ipblocks = self.client.list_ipblocks()

        self.assertGreater(len(ipblocks), 0)
        self.assertGreater(ipblocks['items'][0]['properties']['size'], 0)
        assertRegex(self, ipblocks['items'][0]['id'], self.resource['uuid_match'])
        self.assertIn(ipblocks['items'][0]['properties']['location'], self.resource['locations'])
开发者ID:jbuchhammer,项目名称:profitbricks-sdk-python,代码行数:7,代码来源:test_ipblock_live.py


示例3: test_list

    def test_list(self):
        servers = self.client.list_servers(datacenter_id=self.datacenter['id'])

        self.assertGreater(len(servers), 0)
        self.assertEqual(servers['items'][0]['type'], 'server')
        self.assertTrue(self, len(servers['items'])>0)
        assertRegex(self, servers['items'][0]['id'], self.resource['uuid_match'])
开发者ID:fbrehm,项目名称:profitbricks-sdk-python,代码行数:7,代码来源:test_server_live.py


示例4: test_panEncryptionAlgo0

 def test_panEncryptionAlgo0(self):
     pan_in = '4876010123456789012'
     panEnc, pan = pci.encrypt(pan_in, None, '00', self.depco)
     # self.assertEqual(pan, pan_in.encode('hex'))
     six.assertRegex(self, panEnc, r'00\d+')
     panClr, data = pci.decrypt(panEnc, self.depco)
     self.assertEqual(pan_in, panClr)
开发者ID:NormanDenayer,项目名称:dep,代码行数:7,代码来源:test_dep.py


示例5: assert_status_of_phase

    def assert_status_of_phase(self, output, status, phase, test_name, xfail=None):
        """Asserts that 'output' contains a line showing the given
        status for the given phase for the given test_name.

        'xfail' should have one of the following values:
        - None (the default): assertion passes regardless of whether there is an
          EXPECTED/UNEXPECTED string
        - 'no': The line should end with the phase, with no additional text after that
        - 'expected': After the phase, the line should contain '(EXPECTED FAILURE)'
        - 'unexpected': After the phase, the line should contain '(UNEXPECTED'
        """
        expected = (r'^ *{} +'.format(re.escape(status)) +
                    self._test_name_and_phase_regex(test_name, phase))

        if xfail == 'no':
            # There should be no other text after the testname and phase regex
            expected += r' *$'
        elif xfail == 'expected':
            expected += r' *{}'.format(re.escape(test_status.TEST_EXPECTED_FAILURE_COMMENT))
        elif xfail == 'unexpected':
            expected += r' *{}'.format(re.escape(test_status.TEST_UNEXPECTED_FAILURE_COMMENT_START))
        else:
            expect(xfail is None, "Unhandled value of xfail argument")

        expected_re = re.compile(expected, flags=re.MULTILINE)
        six.assertRegex(self, output, expected_re)
开发者ID:fischer-ncar,项目名称:cime,代码行数:26,代码来源:custom_assertions_test_status.py


示例6: test_node_default_attrs

 def test_node_default_attrs(self):
     tasks = [
         {'id': 'task-A'},
     ]
     dotgraph = self.get_dotgraph_with_tasks(tasks)
     six.assertRegex(self, dotgraph, '"task-A" .*color=yellowgreen.*;')
     six.assertRegex(self, dotgraph, '"task-A" .*style=filled.*;')
开发者ID:ekorekin,项目名称:fuel-web,代码行数:7,代码来源:test_graph.py


示例7: testKeyFile

    def testKeyFile(self):
        # Make sure sha512 appears in returned file documents
        resp = self.request('/file/%s' % self.publicFile['_id'])
        self.assertStatusOk(resp)
        self.assertEqual(resp.json['sha512'], self.publicFile['sha512'])

        template = '/file/%s/hashsum_file/%s'

        # Test with bad algo
        resp = self.request(template % (self.publicFile['_id'], 'foo'))
        self.assertStatus(resp, 400)
        six.assertRegex(self, resp.json['message'], '^Invalid value for algo: "foo"')

        # Should work with public file
        resp = self.request(template % (self.publicFile['_id'], 'sha512'),
                            isJson=False)
        self.assertStatusOk(resp)
        respBody = self.getBody(resp)
        self.assertEqual(respBody, '%s\n' % self.publicFile['sha512'])
        self.assertEqual(len(respBody), 129)

        # Should not work with private file
        resp = self.request(template % (self.privateFile['_id'], 'sha512'))
        self.assertStatus(resp, 401)
        six.assertRegex(self, resp.json['message'], '^Read access denied')
开发者ID:data-exp-lab,项目名称:girder,代码行数:25,代码来源:hashsum_download_test.py


示例8: test_list_images

    def test_list_images(self):
        images = self.client.list_images()

        assertRegex(self, images['items'][0]['id'], self.resource['uuid_match'])
        self.assertGreater(len(images), 0)
        self.assertEqual(images['items'][0]['type'], 'image')
        self.assertTrue(self, len(images['items']) > 0)
开发者ID:fbrehm,项目名称:profitbricks-sdk-python,代码行数:7,代码来源:test_image_live.py


示例9: test_create_complex

    def test_create_complex(self):
        fwrule = FirewallRule(**self.resource['fwrule'])
        nic = NIC(firewall_rules=[fwrule], **self.resource['nic'])
        volume = Volume(image=self.image['id'],
                        image_password='secretpassword123',
                        ssh_keys=['ssh-rsa AAAAB3NzaC1'],
                        **self.resource['volume'])

        server = Server(
            nics=[nic],
            create_volumes=[volume],
            **self.resource['server'])

        composite_server = self.client.create_server(
            datacenter_id=self.datacenter['id'],
            server=server)
        wait_for_completion(self.client, composite_server, 'create_server', wait_timeout=600)

        composite_server = self.client.get_server(
            datacenter_id=self.datacenter['id'],
            server_id=composite_server['id'])

        assertRegex(self, composite_server['id'], self.resource['uuid_match'])
        self.assertEqual(composite_server['properties']['name'], self.resource['server']['name'])
        self.assertEqual(composite_server['properties']['cores'], self.resource['server']['cores'])
        self.assertEqual(composite_server['properties']['ram'], self.resource['server']['ram'])
        self.assertEqual(composite_server['properties']['availabilityZone'], 'AUTO')
        self.assertIn(composite_server['properties']['vmState'], self.resource['vm_states'])
开发者ID:jbuchhammer,项目名称:profitbricks-sdk-python,代码行数:28,代码来源:test_server_live.py


示例10: test_unset_http_equiv_2

 def test_unset_http_equiv_2(self):
     htmlmeta_hub.pyramid_helpers.htmlmeta_set('refresh', '15', request=self.request)
     b = htmlmeta_hub.pyramid_helpers.htmlmeta_as_html(request=self.request)
     six.assertRegex(self, b, re_refresh_15)
     htmlmeta_hub.pyramid_helpers.htmlmeta_unset('refresh', request=self.request)
     b = htmlmeta_hub.pyramid_helpers.htmlmeta_as_html(request=self.request)
     self.assertNotRegexpMatches(b, re_refresh_15)
开发者ID:jvanasco,项目名称:htmlmeta_hub,代码行数:7,代码来源:tests.py


示例11: test_encryptlist

 def test_encryptlist(self):
     enc_data = best.encryptlist(self.depco,
                             ['67033111201401507', '67033111201401556'],
                             '20AEC80DEC6474265EA3657B8D8BAA0DEE5058',
                             key_variant='01', ksk='01',
                             enc2key='00000000000000201508281410376874')
     for elt in enc_data:
         six.assertRegex(self, elt, r'^[A-F0-9]{32}$')
开发者ID:NormanDenayer,项目名称:dep,代码行数:8,代码来源:test_dep.py


示例12: test_encrypt_ecb

 def test_encrypt_ecb(self):
     e2k, enc_data = best.encrypt(self.depco,
                                  '0102030401020304',
                                  'B426EE161E95AAE7EBE131D4BF63C71F15F2D8',
                                   ksk='01',
                                   enc2key='00000000000000201508281410361909')
     six.assertRegex(self, enc_data, r'^[A-F0-9]{16}')
     six.assertRegex(self, e2k, r'^[A-F0-9]{32}$')
开发者ID:NormanDenayer,项目名称:dep,代码行数:8,代码来源:test_dep.py


示例13: assert_status_of_phase

    def assert_status_of_phase(self, output, status, phase, test_name):
        """Asserts that 'output' contains a line showing the given
        status for the given phase for the given test_name"""
        expected = re.compile(r'^ *{} +'.format(re.escape(status)) +
                              self._test_name_and_phase_regex(test_name, phase),
                              flags=re.MULTILINE)

        six.assertRegex(self, output, expected)
开发者ID:bertinia,项目名称:cime,代码行数:8,代码来源:test_cs_status.py


示例14: test_get_ipblock

    def test_get_ipblock(self):
        ipblock = self.client.get_ipblock(self.ipblock1['id'])

        assertRegex(self, ipblock['id'], self.resource['uuid_match'])
        self.assertEqual(ipblock['id'], self.ipblock1['id'])
        self.assertEqual(ipblock['properties']['name'], (self.resource['ipblock']['name']))
        self.assertEqual(ipblock['properties']['size'], self.resource['ipblock']['size'])
        self.assertEqual(ipblock['properties']['location'], self.resource['ipblock']['location'])
开发者ID:fbrehm,项目名称:profitbricks-sdk-python,代码行数:8,代码来源:test_ipblock_live.py


示例15: test_print_report

    def test_print_report(self):
        io = six.StringIO()
        self.h.print_report(unit=self.unit, file=io)
        expect = r'''\AFunctionName  UsedBytes  AcquiredBytes  Occurrence
 +Exp +[0-9.\-e]+.?B +[0-9.\-e]+.?B +[0-9]+
 +ReLU +[0-9.\-e]+.?B +[0-9.\-e]+.?B +[0-9]+$
'''
        actual = io.getvalue()
        six.assertRegex(self, actual, expect)
开发者ID:asi1024,项目名称:chainer,代码行数:9,代码来源:test_cupy_memory_profile.py


示例16: assertQuickReplyLinks

 def assertQuickReplyLinks(self, output):
     """Assert reply links created by setup_quick_replies are present."""
     link = r'data-qr="%s">\s*%s\s*</a>'
     six.assertRegex(
         self, output.get_data(as_text=True), link % (self.r1, self.sr1)
     )
     six.assertRegex(
         self, output.get_data(as_text=True), link % (self.r2, self.sr2)
     )
开发者ID:pypingou,项目名称:pagure,代码行数:9,代码来源:test_pagure_flask_ui_quick_reply.py


示例17: test_create_simple

 def test_create_simple(self):
     # Use server created dring server test setup
     assertRegex(self, self.server['id'], self.resource['uuid_match'])
     self.assertEqual(self.server['type'], 'server')
     self.assertEqual(self.server['properties']['name'], self.resource['server']['name'])
     self.assertEqual(self.server['properties']['cores'], self.resource['server']['cores'])
     self.assertEqual(self.server['properties']['ram'], self.resource['server']['ram'])
     self.assertIsNone(self.server['properties']['availabilityZone'])
     self.assertIsNone(self.server['properties']['vmState'])
开发者ID:jbuchhammer,项目名称:profitbricks-sdk-python,代码行数:9,代码来源:test_server_live.py


示例18: testRunfilesLibrariesFindRunfilesWithoutEnvvars

  def testRunfilesLibrariesFindRunfilesWithoutEnvvars(self):
    for s, t, exe in [
        ("WORKSPACE.mock", "WORKSPACE", False),
        ("bar/BUILD.mock", "bar/BUILD", False),
        ("bar/bar.py", "bar/bar.py", True),
        ("bar/bar-py-data.txt", "bar/bar-py-data.txt", False),
        ("bar/Bar.java", "bar/Bar.java", False),
        ("bar/bar-java-data.txt", "bar/bar-java-data.txt", False),
        ("bar/bar.sh", "bar/bar.sh", True),
        ("bar/bar-sh-data.txt", "bar/bar-sh-data.txt", False),
        ("bar/bar.cc", "bar/bar.cc", False),
        ("bar/bar-cc-data.txt", "bar/bar-cc-data.txt", False),
    ]:
      self.CopyFile(
          self.Rlocation("io_bazel/src/test/py/bazel/testdata/runfiles_test/" +
                         s), t, exe)

    exit_code, stdout, stderr = self.RunBazel(["info", "bazel-bin"])
    self.AssertExitCode(exit_code, 0, stderr)
    bazel_bin = stdout[0]

    exit_code, _, stderr = self.RunBazel([
        "build", "--verbose_failures",
        "//bar:bar-py", "//bar:bar-java", "//bar:bar-sh", "//bar:bar-cc"
    ])
    self.AssertExitCode(exit_code, 0, stderr)

    for lang in [("py", "Python", "bar.py"), ("java", "Java", "Bar.java"),
                 ("sh", "Bash", "bar.sh"), ("cc", "C++", "bar.cc")]:
      if test_base.TestBase.IsWindows():
        bin_path = os.path.join(bazel_bin, "bar/bar-%s.exe" % lang[0])
      else:
        bin_path = os.path.join(bazel_bin, "bar/bar-" + lang[0])

      self.assertTrue(os.path.exists(bin_path))

      exit_code, stdout, stderr = self.RunProgram(
          [bin_path],
          env_remove=set([
              "RUNFILES_MANIFEST_FILE",
              "RUNFILES_MANIFEST_ONLY",
              "RUNFILES_DIR",
              "JAVA_RUNFILES",
          ]),
          env_add={"TEST_SRCDIR": "__ignore_me__"})
      self.AssertExitCode(exit_code, 0, stderr)
      if len(stdout) < 2:
        self.fail("stdout(%s): %s" % (lang[0], stdout))
      self.assertEqual(stdout[0], "Hello %s Bar!" % lang[1])
      six.assertRegex(self, stdout[1], "^rloc=.*/bar/bar-%s-data.txt" % lang[0])
      self.assertNotIn("__ignore_me__", stdout[1])

      with open(stdout[1].split("=", 1)[1], "r") as f:
        lines = [l.strip() for l in f.readlines()]
      if len(lines) != 1:
        self.fail("lines(%s): %s" % (lang[0], lines))
      self.assertEqual(lines[0], "data for " + lang[2])
开发者ID:davido,项目名称:bazel,代码行数:57,代码来源:runfiles_test.py


示例19: test_encrypt_cbc_variant

 def test_encrypt_cbc_variant(self):
     e2k, enc_data = best.encrypt(self.depco,
                                  '0102030401020304',
                                  '20AEC80DEC6474265EA3657B8D8BAA0DEE5058',
                                  ksk='01', key_variant='01', ecb=False,
                                  iv='0000000000000000',
                                  enc2key='00000000000000201508281410348350')
     six.assertRegex(self, enc_data, r'^[A-F0-9]{16}$')
     six.assertRegex(self, e2k, r'^[A-F0-9]{32}$')
开发者ID:NormanDenayer,项目名称:dep,代码行数:9,代码来源:test_dep.py


示例20: test_bad_value

 def test_bad_value(self):
     # A bad value should be ignored and replaced with the default value.
     bad_value = 'wibble'
     with warnings.catch_warnings(record=True) as w:
         warnings.simplefilter('always')
         self.options.conventions_override = bad_value
     self.assertFalse(self.options.conventions_override)
     exp_wmsg = 'Attempting to set invalid value {!r}'.format(bad_value)
     six.assertRegex(self, str(w[0].message), exp_wmsg)
开发者ID:SciTools,项目名称:iris,代码行数:9,代码来源:test_NetCDF.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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