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

Python tools.assert_regexp_matches函数代码示例

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

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



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

示例1: check_release

def check_release(package, data):
    for key in data.keys():
        assert_not_in(key, ['version', 'date', 'url'], 'The version, date and ' + \
            'url keys should not be used in the main repository since a pull ' + \
            'request would be necessary for every release')

        assert_in(key, ['details', 'sublime_text', 'platforms'])

        if key in ['details', 'url']:
            assert_regexp_matches(data[key], '^https?://')

        if key == 'sublime_text':
            assert_regexp_matches(data[key], '^(\*|<=?\d{4}|>=?\d{4})$')

        if key == 'platforms':
            assert_in(type(data[key]), [str, list])
            if type(data[key]) == str:
                assert_in(data[key], ['*', 'osx', 'linux', 'windows'])
            else:
                for platform in data[key]:
                    assert_in(platform, ['*', 'osx', 'linux', 'windows'])

    assert_in('details', data, 'A release must have a "details" key if it is in ' + \
        'the main repository. For custom releases, a custom repository.json ' + \
        'file must be hosted elsewhere.')
开发者ID:JeremyRoundill,项目名称:package_control_channel,代码行数:25,代码来源:test.py


示例2: test_local_mode

def test_local_mode():
    mailer = create_mailer({"mode": "local"})
    mailer.find_core = lambda: __file__
    mailer.get_trace = lambda _: "some traces"
    mailer.out = StringIO()
    mailer.run()
    assert_regexp_matches(mailer.out.getvalue(), "some traces")
开发者ID:FihlaTV,项目名称:docker-stellar-core,代码行数:7,代码来源:core_file_processor_test.py


示例3: test_non_sysadmin_changes_related_items_featured_field_fails

    def test_non_sysadmin_changes_related_items_featured_field_fails(self):
        '''Non-sysadmins cannot change featured field'''

        context = {
            'model': model,
            'user': 'annafan',
            'session': model.Session
        }

        data_dict = {
            'title': 'Title',
            'description': 'Description',
            'type': 'visualization',
            'url': 'http://ckan.org',
            'image_url': 'http://ckan.org/files/2012/03/ckanlogored.png',
        }

        # Create the related item as annafan
        result = logic.get_action('related_create')(context, data_dict)

        # Try to change it to a featured item
        result['featured'] = 1

        try:
            logic.get_action('related_update')(context, result)
        except logic.NotAuthorized, e:
            # Check it's the correct authorization error
            assert_regexp_matches(str(e), 'featured')
开发者ID:Open-Source-GIS,项目名称:ckan,代码行数:28,代码来源:test_related.py


示例4: test_tab_about

 def test_tab_about(self):
     # look for serial number
     about_page = self.app.get("/config/about/")
     assert_equal(about_page.status_int, 200)
     assert_regexp_matches(
         about_page.body,
         r"|".join(self.AVAILABLE_DEVICES),
         "This test suite is not adjusted for this device.",
     )
     sn_match = re.search(r"<td>(\d+)</td>", about_page.body)
     assert_true(sn_match)
     try:
         sn = int(sn_match.group(1))
     except ValueError:
         raise AssertionError("Router serial number is not integer.")
     # should work on routers from first production Turris 1.0 till new Turris 1.1
     in_range = False
     for first, last in self.AVAILABLE_SERIALS:
         if first < sn < last:
             in_range = True
     assert_true(
         in_range,
         "Serial %d not in range %s "
         % (sn, ", ".join([repr(e) for e in self.AVAILABLE_SERIALS])),
     )
开发者ID:CZ-NIC,项目名称:foris,代码行数:25,代码来源:functional_tests.py


示例5: test_get_links

def test_get_links(mock_retrieve):
    """
    How are search hits links split from the results page
    """
    query = "Finalize object in Scala"
    # these were the answers on August 5 2015
    mock_retrieve.return_value = read_fixed_data('search_hits_scala.html')
    search_hits = pbs.lookup.get_search_hits(query)
    links = search_hits.links
    nt.assert_equal(10, len(links))
    expected_regexp = (
        r'/url\?q='                     # matched literally
        r'http://stackoverflow\.com'    # matched literally with escaped dot
        r'/questions/\d+'               # question id
        r'/[a-z\-]+'                    # question title
        r'&sa=U&ved=\w{40}&usg=\S{34}'  # params: two hashes
    )
    for link in links:
        nt.assert_regexp_matches(link, expected_regexp)
    expected_titles = [
        'how-to-write-a-class-destructor-in-scala',
        'when-is-the-finalize-method-called-in-java',
        'is-there-a-destructor-for-java',
        'java-memory-leak-destroy-finalize-object',
        'what-guarantees-does-java-scala-make-about-garbage-collection',
        'what-is-the-best-way-to-clean-up-an-object-in-java',
        'what-is-the-cause-of-this-strange-scala-memory-leak',
        'java-executing-a-method-when-objects-scope-ends',
        'luajava-call-methods-on-lua-object-from-java',
        'how-to-prevent-an-object-from-getting-garbage-collected'
    ]
    for link, title in zip(links, expected_titles):
        nt.assert_true(title in link)
开发者ID:NacionLumpen,项目名称:pbs,代码行数:33,代码来源:test_lookup.py


示例6: test_copy_verse_range

def test_copy_verse_range(out):
    '''should copy reference content for verse range'''
    yvs.main('111/psa.23.1-2')
    ref_content = out.getvalue()
    assert_regexp_matches(ref_content, 'Lorem')
    assert_regexp_matches(ref_content, 'nunc nulla')
    assert_not_regexp_matches(ref_content, 'fermentum')
开发者ID:bondezbond,项目名称:youversion-suggest,代码行数:7,代码来源:test_copy_ref.py


示例7: test_registration_code

 def test_registration_code(self):
     res = self.app.get("/config/about/ajax?action=registration_code",
                        headers=XHR_HEADERS)
     payload = res.json
     assert_true(payload['success'])
     # check that code is not empty
     assert_regexp_matches(payload['data'], r"[0-9A-F]{8}")
开发者ID:jtojnar,项目名称:foris,代码行数:7,代码来源:functional_tests.py


示例8: test_inherit

def test_inherit():
    # _shared is not included in apps that don't explicitly define it
    data = dict(cc.parse('test', CWD))

    for key in data:
        nt.assert_regexp_matches(key, r'^test.*')
    for app in ['test/app2']:
        nt.assert_equal(data[app], {'key1': 'val1'})

    # _shared should not get included in apps that define _inherit
    for app in ['test', 'test/app1', 'test/app3']:
        nt.assert_equal(data[app], {})
    nt.assert_dict_equal(data['test/app4'], {'key2': 'val2'})
    nt.assert_dict_equal(data['test/app5'], {'key1': 'val1', 'key2': 'val2'})
    nt.assert_dict_equal(data['test/app6'], {"key1": "val11"})
    nt.assert_dict_equal(data['test/app7'], {'key1': 'val11', 'key2': 'val2'})
    nt.assert_dict_equal(data['test/app8'], {'key1': 'val1', 'key2': 'val22'})
    nt.assert_dict_equal(data['test/app9'], {'key1': 'val1', 'key2': 'val222'})

    nt.assert_dict_equal(data['test/app20'], {'key': 'value'})
    nt.assert_dict_equal(data['test/app21'], {'key': 'value', 'key1': 'val1'})
    nt.assert_dict_equal(data['test/app22'], {'key1': 'val1'})

    data = dict(cc.parse('test-ns2', CWD))
    nt.assert_dict_equal(data['test-ns2'], {'key1': 'val1'})
开发者ID:sailthru,项目名称:consulconf,代码行数:25,代码来源:test_consulconf.py


示例9: test_invalid_msg_from_string

def test_invalid_msg_from_string():
    
    with assert_raises(IpcMessageException) as cm:
        invalid_msg = IpcMessage(from_str="{\"wibble\" : \"wobble\" \"shouldnt be here\"}")
    ex = cm.exception
    assert_regexp_matches(ex.msg, "Illegal message JSON format*")
                            
       
开发者ID:ulrikpedersen,项目名称:framereceiver,代码行数:6,代码来源:test_ipc_message.py


示例10: test_whitespace_words

def test_whitespace_words(out):
    '''should handle spaces appropriately'''
    yvs.main('111/psa.23')
    ref_content = out.getvalue()
    assert_regexp_matches(ref_content, 'adipiscing elit.',
                          'should respect content consisting of spaces')
    assert_regexp_matches(ref_content, 'consectetur adipiscing',
                          'should collapse consecutive spaces')
开发者ID:bondezbond,项目名称:youversion-suggest,代码行数:8,代码来源:test_copy_ref.py


示例11: test_google_search

def test_google_search():
    global browser
    browser.go_to('http://www.google.com')
    browser.wait_for_page(Google.Home)
    browser.click_and_type(Google.Home.Search_Query_Text_Field, "Slick Test Manager")
    browser.click(Google.Home.Search_Button)
    browser.wait_for_page(Google.SearchResults)
    assert_regexp_matches(browser.get_page_text(), '.*SlickQA:.*')
开发者ID:slickqa,项目名称:slick-webdriver-python,代码行数:8,代码来源:searchtests.py


示例12: test_not_loadable

	def test_not_loadable(self):
		base = os.path.dirname(__file__)
		exp_path = os.path.join(base, 'fixtures', 'not_loadable.h5')
		s = load_solver(exp_path, 'main')
		len(s) # ensure we can load the events
		# check that solver_info is set:
		info = s.store['solver_info']
		nt.assert_regexp_matches(info['system_class'], 'NoSystem')
开发者ID:LongyanU,项目名称:odelab,代码行数:8,代码来源:test_experiment.py


示例13: test_404_error_is_raise_when_vm_dont_exist

 def test_404_error_is_raise_when_vm_dont_exist(self):
     """
     Test that get raises an 404 error if the VM does not exist
     """
     self.server.set_xml_response("vms/123", 404, "")
     with assert_raises(ovirtsdk4.NotFoundError) as context:
         self.vms_service.vm_service('123').get()
     assert_regexp_matches(str(context.exception), "404")
开发者ID:oVirt,项目名称:ovirt-engine-sdk,代码行数:8,代码来源:test_vm_service.py


示例14: test_prepare_path

def test_prepare_path():
    import os
    import shutil
    base_path = '~/.tidml/prepared_path/'
    file_name = 'the_file'
    shutil.rmtree(os.path.expanduser(base_path), ignore_errors=True)
    pp = prepare_path(base_path + file_name)
    nt.assert_regexp_matches(pp, '/Users/(.)+/\.tidml/prepared_path/the_file')
开发者ID:tidchile,项目名称:tidml,代码行数:8,代码来源:utils_tests.py


示例15: assert_eq_dic

 def assert_eq_dic(self, dict1, dict2):		# Compare two dictionaries
     for x in dict2.keys():
         if not isinstance(dict2[x], dict):
             if isinstance(dict2[x], list):
                 self.assert_eq_dic_lst(dict1[x], dict2[x])
             else:
                 assert_regexp_matches(str(dict1[x]), str(dict2[x]), msg="Error in '{k}': '{v1}' not matched '{v2}'".format(k = x, v1 = str(dict1[x]), v2 = str(dict2[x])))
         else:
             self.assert_eq_dic(dict1[x], dict2[x])
开发者ID:alex7kir,项目名称:paypal_tests,代码行数:9,代码来源:common_helper.py


示例16: test_super_repr

def test_super_repr():
    # "<super: module_name.SA, None>"
    output = pretty.pretty(super(SA))
    nt.assert_regexp_matches(output, r"<super: \S+.SA, None>")

    # "<super: module_name.SA, <module_name.SB at 0x...>>"
    sb = SB()
    output = pretty.pretty(super(SA, sb))
    nt.assert_regexp_matches(output, r"<super: \S+.SA,\s+<\S+.SB at 0x\S+>>")
开发者ID:AFred38,项目名称:webfai,代码行数:9,代码来源:test_pretty.py


示例17: find_grade_report_csv_link

def find_grade_report_csv_link(step):  # pylint: disable=unused-argument
    # Need to reload the page to see the grades download table
    reload_the_page(step)
    world.wait_for_visible('#report-downloads-table')
    # Find table and assert a .csv file is present
    expected_file_regexp = 'edx_999_Test_Course_grade_report_\d{4}-\d{2}-\d{2}-\d{4}\.csv'
    assert_regexp_matches(
        world.css_html('#report-downloads-table'), expected_file_regexp,
        msg="Expected grade report filename was not found."
    )
开发者ID:Cuentafalsa,项目名称:edx-platform,代码行数:10,代码来源:data_download.py


示例18: verify_report_is_generated

def verify_report_is_generated(report_name_substring):
    # Need to reload the page to see the reports table updated
    reload_the_page(step)
    world.wait_for_visible("#report-downloads-table")
    # Find table and assert a .csv file is present
    quoted_id = http.urlquote(world.course_key).replace("/", "_")
    expected_file_regexp = quoted_id + "_" + report_name_substring + "_\d{4}-\d{2}-\d{2}-\d{4}\.csv"
    assert_regexp_matches(
        world.css_html("#report-downloads-table"), expected_file_regexp, msg="Expected report filename was not found."
    )
开发者ID:mrstephencollins,项目名称:edx-platform,代码行数:10,代码来源:data_download.py


示例19: test_main

def test_main():
    """main function should produce some output"""
    out = io.StringIO()
    with contextlib.redirect_stdout(out):
        sim.main()
    main_output = out.getvalue()
    nose.assert_regexp_matches(main_output, r'\bWordAddr\b')
    nose.assert_regexp_matches(main_output, r'\b0110\b')
    nose.assert_regexp_matches(main_output, r'\bCache')
    nose.assert_regexp_matches(main_output, r'\b01\b')
    nose.assert_regexp_matches(main_output, r'\b8\s*6\b')
开发者ID:caleb531,项目名称:cache-simulator,代码行数:11,代码来源:test_simulator_main.py


示例20: find_grade_report_csv_link

def find_grade_report_csv_link(step):  # pylint: disable=unused-argument
    # Need to reload the page to see the grades download table
    reload_the_page(step)
    world.wait_for_visible('#report-downloads-table')
    # Find table and assert a .csv file is present
    quoted_id = http.urlquote(world.course_key).replace('/', '_')
    expected_file_regexp = quoted_id + '_grade_report_\d{4}-\d{2}-\d{2}-\d{4}\.csv'
    assert_regexp_matches(
        world.css_html('#report-downloads-table'), expected_file_regexp,
        msg="Expected grade report filename was not found."
    )
开发者ID:nchuopenedx,项目名称:edx-platform,代码行数:11,代码来源:data_download.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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