本文整理汇总了Python中nose.tools.assert_regexp_matches函数的典型用法代码示例。如果您正苦于以下问题:Python assert_regexp_matches函数的具体用法?Python assert_regexp_matches怎么用?Python assert_regexp_matches使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_regexp_matches函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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.')
示例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")
示例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')
示例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])),
)
示例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)
示例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')
示例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}")
示例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'})
示例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*")
示例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')
示例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:.*')
示例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')
示例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")
示例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')
示例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])