本文整理汇总了Python中nose.tools.assert_equals函数的典型用法代码示例。如果您正苦于以下问题:Python assert_equals函数的具体用法?Python assert_equals怎么用?Python assert_equals使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_equals函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_edit_issue
def test_edit_issue(self):
# goto issue show page
env = {'REMOTE_USER': self.owner['name'].encode('ascii')}
response = self.app.get(
url=toolkit.url_for('issues_show',
dataset_id=self.dataset['id'],
issue_number=self.issue['number']),
extra_environ=env,
)
# click the edit link
response = response.click(linkid='issue-edit-link', extra_environ=env)
# fill in the form
form = response.forms['issue-edit']
form['title'] = 'edited title'
form['description'] = 'edited description'
# save the form
response = helpers.webtest_submit(form, 'save', extra_environ=env)
response = response.follow()
# make sure it all worked
assert_in('edited title', response)
assert_in('edited description', response)
result = helpers.call_action('issue_show',
dataset_id=self.dataset['id'],
issue_number=self.issue['number'])
assert_equals(u'edited title', result['title'])
assert_equals(u'edited description', result['description'])
示例2: test_get_many_objects
def test_get_many_objects(self):
ct_ct = ContentType.objects.get_for_model(ContentType)
site_ct = ContentType.objects.get_for_model(Site)
objs = utils.get_cached_objects([(ct_ct.id, ct_ct.id), (ct_ct.id, site_ct.id), (site_ct.id, 1)])
tools.assert_equals([ct_ct, site_ct, Site.objects.get(pk=1)], objs)
示例3: test_after_each_step_is_executed_before_each_step
def test_after_each_step_is_executed_before_each_step():
"terrain.before.each_step and terrain.after.each_step decorators"
world.step_states = []
@before.each_step
def set_state_to_before(step):
world.step_states.append('before')
expected = 'Given I append "during" to states'
if step.sentence != expected:
raise TypeError('%r != %r' % (step.sentence, expected))
@step('append "during" to states')
def append_during_to_step_states(step):
world.step_states.append("during")
@after.each_step
def set_state_to_after(step):
world.step_states.append('after')
expected = 'Given I append "during" to states'
if step.sentence != expected:
raise TypeError('%r != %r' % (step.sentence, expected))
feature = Feature.from_string(FEATURE1)
feature.run()
assert_equals(world.step_states, ['before', 'during', 'after'])
示例4: test_role_user_state3_perms
def test_role_user_state3_perms(self):
"""
Testing user permission in state3.
"""
api_key = self.__login("user", "pass3")
headers = self.__build_headers("user", api_key)
test_author = Author.objects.create(id=100, name="dumb_name")
set_state(test_author, self.state3)
response = self.client.post("/admin-api/author/", data=self.new_author,
content_type='application/json', **headers)
tools.assert_equals(response.status_code, 201)
response = self.client.get("/admin-api/author/100/", **headers)
tools.assert_equals(response.status_code, 200)
response = self.client.put("/admin-api/author/100/", data=self.new_author,
content_type='application/json', **headers)
tools.assert_equals(response.status_code, 401)
response = self.client.patch("/admin-api/author/100/", data=self.new_author,
content_type='application/json', **headers)
tools.assert_equals(response.status_code, 401)
response = self.client.delete("/admin-api/author/100/", **headers)
tools.assert_equals(response.status_code, 401)
self.__logout(headers)
示例5: test_create_object_from_doc
def test_create_object_from_doc(self):
new_object = provider_batch_data.create_objects_from_doc(self.old_doc)
matching = ProviderBatchData.query.filter_by(provider="pmc").first()
assert_equals(matching.provider, "pmc")
assert_equals(matching.aliases, self.old_doc["aliases"])
示例6: test_class_tags
def test_class_tags():
xblock = XBlock(None, None)
assert_equals(xblock._class_tags, set())
class Sub1Block(XBlock):
pass
sub1block = Sub1Block(None, None)
assert_equals(sub1block._class_tags, set())
@XBlock.tag("cat dog")
class Sub2Block(Sub1Block):
pass
sub2block = Sub2Block(None, None)
assert_equals(sub2block._class_tags, set(["cat", "dog"]))
class Sub3Block(Sub2Block):
pass
sub3block = Sub3Block(None, None)
assert_equals(sub3block._class_tags, set(["cat", "dog"]))
@XBlock.tag("mixin")
class MixinBlock(XBlock):
pass
class Sub4Block(MixinBlock, Sub3Block):
pass
sub4block = Sub4Block(None, None)
assert_equals(sub4block._class_tags, set(["cat", "dog", "mixin"]))
示例7: test_import_class
def test_import_class():
assert_raises(ImproperlyConfigured, import_class,
'rapidsms.tests.router.test_base.BadClassName')
assert_raises(ImproperlyConfigured, import_class,
'rapidsms.tests.router.bad_module.MockRouter')
assert_equals(import_class('rapidsms.tests.router.test_base.MockRouter'),
MockRouter)
示例8: test_indentation
def test_indentation():
"""Test correct indentation in groups"""
count = 40
gotoutput = pretty.pretty(MyList(range(count)))
expectedoutput = "MyList(\n" + ",\n".join(" %d" % i for i in range(count)) + ")"
nt.assert_equals(gotoutput, expectedoutput)
示例9: check_triangulation
def check_triangulation(embedding, expected_embedding):
res_embedding, _ = triangulate_embedding(embedding, True)
assert_equals(res_embedding.get_data(), expected_embedding,
"Expected embedding incorrect")
res_embedding, _ = triangulate_embedding(embedding, False)
assert_equals(res_embedding.get_data(), expected_embedding,
"Expected embedding incorrect")
示例10: test_render_any_markup_formatting
def test_render_any_markup_formatting():
assert_equals(h.render_any_markup('README.md', '### foo\n'
' <script>alert(1)</script> bar'),
'<div class="markdown_content"><h3 id="foo">foo</h3>\n'
'<div class="codehilite"><pre><span class="nt">'
'<script></span>alert(1)<span class="nt">'
'</script></span> bar\n</pre></div>\n\n</div>')
示例11: test_package_create
def test_package_create(self):
idf.plugin_v4.create_country_codes()
result = helpers.call_action('package_create', name='test_package',
custom_text='this is my custom text',
country_code='uk')
nt.assert_equals('this is my custom text', result['custom_text'])
nt.assert_equals([u'uk'], result['country_code'])
示例12: test_storage_url_not_exists
def test_storage_url_not_exists(mock_storage):
mock_storage.exists.return_value = False
mock_storage.url.return_value = '/static/data_dir/file.png'
assert_equals('"/static/data_dir/file.png"', replace_static_urls(STATIC_SOURCE, DATA_DIRECTORY))
mock_storage.exists.assert_called_once_with('file.png')
mock_storage.url.assert_called_once_with('data_dir/file.png')
示例13: test_process_url_data_dir_exists
def test_process_url_data_dir_exists():
base = '"/static/{data_dir}/file.png"'.format(data_dir=DATA_DIRECTORY)
def processor(original, prefix, quote, rest): # pylint: disable=unused-argument,missing-docstring
return quote + 'test' + rest + quote
assert_equals(base, process_static_urls(base, processor, data_dir=DATA_DIRECTORY))
示例14: check_inheritable_attribute
def check_inheritable_attribute(self, attribute, value):
# `attribute` isn't a basic attribute of Sequence
assert_false(hasattr(SequenceDescriptor, attribute))
# `attribute` is added by InheritanceMixin
assert_true(hasattr(InheritanceMixin, attribute))
root = SequenceFactory.build(policy={attribute: str(value)})
ProblemFactory.build(parent=root)
# InheritanceMixin will be used when processing the XML
assert_in(InheritanceMixin, root.xblock_mixins)
seq = self.process_xml(root)
assert_equals(seq.unmixed_class, SequenceDescriptor)
assert_not_equals(type(seq), SequenceDescriptor)
# `attribute` is added to the constructed sequence, because
# it's in the InheritanceMixin
assert_equals(value, getattr(seq, attribute))
# `attribute` is a known attribute, so we shouldn't include it
# in xml_attributes
assert_not_in(attribute, seq.xml_attributes)
示例15: test_serialize
def test_serialize(self):
"""Objects are serialized to JSON-compatible objects"""
def epoch(obj):
"""Convert to JS Epoch time"""
return int(time.mktime(obj.timetuple())) * 1000
types = [('test', str, 'test'),
(pd.Timestamp('2013-06-08'), int,
epoch(pd.Timestamp('2013-06-08'))),
(datetime.utcnow(), int, epoch(datetime.utcnow())),
(1, int, 1),
(1.0, float, 1.0),
(np.float32(1), float, 1.0),
(np.int32(1), int, 1),
(np.float64(1), float, 1.0),
(np.int64(1), int, 1)]
for puts, pytype, gets in types:
nt.assert_equal(Data.serialize(puts), gets)
class BadType(object):
"""Bad object for type warning"""
test_obj = BadType()
with nt.assert_raises(LoadError) as err:
Data.serialize(test_obj)
nt.assert_equals(err.exception.message,
'cannot serialize index of type BadType')