本文整理汇总了Python中nose.tools.assert_in函数的典型用法代码示例。如果您正苦于以下问题:Python assert_in函数的具体用法?Python assert_in怎么用?Python assert_in使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_in函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: find_student_profile_table
def find_student_profile_table(step): # pylint: disable=unused-argument
# Find the grading configuration display
world.wait_for_visible('#data-student-profiles-table')
# Wait for the data table to be populated
world.wait_for(lambda _: world.css_text('#data-student-profiles-table') not in [u'', u'Loading'])
if world.role == 'instructor':
expected_data = [
world.instructor.username,
world.instructor.email,
world.instructor.profile.name,
world.instructor.profile.gender,
world.instructor.profile.goals
]
elif world.role == 'staff':
expected_data = [
world.staff.username,
world.staff.email,
world.staff.profile.name,
world.staff.profile.gender,
world.staff.profile.goals
]
for datum in expected_data:
assert_in(datum, world.css_text('#data-student-profiles-table'))
示例2: test_mail_user
def test_mail_user(self):
user = factories.User()
user_obj = model.User.by_name(user['name'])
msgs = self.get_smtp_messages()
assert_equal(msgs, [])
# send email
test_email = {'recipient': user_obj,
'subject': 'Meeting',
'body': 'The meeting is cancelled.',
'headers': {'header1': 'value1'}}
mailer.mail_user(**test_email)
# check it went to the mock smtp server
msgs = self.get_smtp_messages()
assert_equal(len(msgs), 1)
msg = msgs[0]
assert_equal(msg[1], config['smtp.mail_from'])
assert_equal(msg[2], [user['email']])
assert test_email['headers'].keys()[0] in msg[3], msg[3]
assert test_email['headers'].values()[0] in msg[3], msg[3]
assert test_email['subject'] in msg[3], msg[3]
expected_body = self.mime_encode(test_email['body'],
user['name'])
assert_in(expected_body, msg[3])
示例3: test_iso19139_failure
def test_iso19139_failure(self):
errors = self.get_validation_errors(validation.ISO19139Schema,
'iso19139/dataset-invalid.xml')
assert len(errors) > 0
assert_in('Dataset schema (gmx.xsd)', errors)
assert_in('{http://www.isotc211.org/2005/gmd}nosuchelement\': This element is not expected.', errors)
示例4: test_RegularizeCustomParam
def test_RegularizeCustomParam(self):
nn = MLPR(layers=[L("Tanh", units=8), L("Linear",)],
weight_decay=0.01,
n_iter=1)
assert_equal(nn.weight_decay, 0.01)
self._run(nn)
assert_in('Using `L2` for regularization.', self.output.getvalue())
示例5: test_DropoutPerLayer
def test_DropoutPerLayer(self):
nn = MLPR(layers=[L("Rectifier", units=8, dropout=0.25), L("Linear")],
regularize='dropout',
n_iter=1)
assert_equal(nn.regularize, 'dropout')
self._run(nn)
assert_in('Using `dropout` for regularization.', self.output.getvalue())
示例6: see_a_single_step_component
def see_a_single_step_component(step):
for step_hash in step.hashes:
component = step_hash['Component']
assert_in(component, ['Discussion', 'Video'])
component_css = 'div.xmodule_{}Module'.format(component)
assert_true(world.is_css_present(component_css),
"{} couldn't be found".format(component))
示例7: test_RegularizeExplicitL1
def test_RegularizeExplicitL1(self):
nn = MLPR(layers=[L("Tanh", units=8), L("Linear",)],
regularize='L1',
n_iter=1)
assert_equal(nn.regularize, 'L1')
self._run(nn)
assert_in('Using `L1` for regularization.', self.output.getvalue())
示例8: test_super_repr
def test_super_repr():
output = pretty.pretty(super(SA))
nt.assert_in("SA", output)
sb = SB()
output = pretty.pretty(super(SA, sb))
nt.assert_in("SA", output)
示例9: _assert_breadcrumbs
def _assert_breadcrumbs(self, document, lot):
# check links exist back to
# (1) digital marketplace,
# (2) cloud tech and support,
# (3) search page for lot
# Hardcoded stuff found in 'views.py'
breadcrumbs_expected = {
'/': 'Digital Marketplace',
'/g-cloud': 'Cloud technology and support',
'/g-cloud/search?lot={}'.format(lot.lower()): self.lots[lot]
}
breadcrumbs = document.xpath('//div[@id="global-breadcrumb"]//a')
assert_equal(3, len(breadcrumbs))
for breadcrumb in breadcrumbs:
breadcrumb_text = breadcrumb.text_content().strip()
breakcrumb_href = breadcrumb.get('href').strip()
# check that the link exists in our expected breadcrumbs
assert_in(
breakcrumb_href, breadcrumbs_expected
)
# check that the link text is the same
assert_equal(
breadcrumb_text, breadcrumbs_expected[breakcrumb_href]
)
示例10: test_json_reports
def test_json_reports(self):
"""Test that json_reports.js works"""
if 'CASPERJS_EXECUTABLE' in os.environ:
casperjs_executable = os.environ['CASPERJS_EXECUTABLE']
else:
casperjs_executable = 'casperjs'
try:
process = Popen(
[
casperjs_executable,
'test', '--json', '--test-self',
os.path.join(
os.path.dirname(__file__),
'../../casper_tests/json_report.js'
)
],
stdout=PIPE,
stderr=PIPE
)
except OSError as e:
return
stdout_data, stderr_data = process.communicate()
assert_in(
'#JSON{"successes":["test json_report.js: a success"],"failures":["test json_report.js: a failure"]}',
stdout_data.split("\n")
)
示例11: test_get_courses_for_wiki
def test_get_courses_for_wiki(self):
"""
Test the get_courses_for_wiki method
"""
for course_number in self.courses:
course_locations = self.draft_store.get_courses_for_wiki(course_number)
assert_equals(len(course_locations), 1)
assert_equals(Location('edX', course_number, '2012_Fall', 'course', '2012_Fall'), course_locations[0])
course_locations = self.draft_store.get_courses_for_wiki('no_such_wiki')
assert_equals(len(course_locations), 0)
# set toy course to share the wiki with simple course
toy_course = self.draft_store.get_course(SlashSeparatedCourseKey('edX', 'toy', '2012_Fall'))
toy_course.wiki_slug = 'simple'
self.draft_store.update_item(toy_course)
# now toy_course should not be retrievable with old wiki_slug
course_locations = self.draft_store.get_courses_for_wiki('toy')
assert_equals(len(course_locations), 0)
# but there should be two courses with wiki_slug 'simple'
course_locations = self.draft_store.get_courses_for_wiki('simple')
assert_equals(len(course_locations), 2)
for course_number in ['toy', 'simple']:
assert_in(Location('edX', course_number, '2012_Fall', 'course', '2012_Fall'), course_locations)
# configure simple course to use unique wiki_slug.
simple_course = self.draft_store.get_course(SlashSeparatedCourseKey('edX', 'simple', '2012_Fall'))
simple_course.wiki_slug = 'edX.simple.2012_Fall'
self.draft_store.update_item(simple_course)
# it should be retrievable with its new wiki_slug
course_locations = self.draft_store.get_courses_for_wiki('edX.simple.2012_Fall')
assert_equals(len(course_locations), 1)
assert_in(Location('edX', 'simple', '2012_Fall', 'course', '2012_Fall'), course_locations)
示例12: test_get_context_data
def test_get_context_data(self):
self.view.draft = self.dr1
res = self.view.get_context_data()
nt.assert_is_instance(res, dict)
nt.assert_in('draft', res)
nt.assert_is_instance(res['draft'], dict)
nt.assert_in('IMMEDIATE', res)
示例13: test_rows
def test_rows():
row_keys = ['rows-row1', 'rows-row2', 'rows-row3']
data_old = {'cf1:col1': 'v1old', 'cf1:col2': 'v2old'}
data_new = {'cf1:col1': 'v1new', 'cf1:col2': 'v2new'}
with assert_raises(TypeError):
table.rows(row_keys, object())
with assert_raises(TypeError):
table.rows(row_keys, timestamp='invalid')
for row_key in row_keys:
table.put(row_key, data_old, timestamp=4000)
for row_key in row_keys:
table.put(row_key, data_new)
assert_dict_equal({}, table.rows([]))
rows = dict(table.rows(row_keys))
for row_key in row_keys:
assert_in(row_key, rows)
assert_dict_equal(data_new, rows[row_key])
rows = dict(table.rows(row_keys, timestamp=5000))
for row_key in row_keys:
assert_in(row_key, rows)
assert_dict_equal(data_old, rows[row_key])
示例14: test_families
def test_families():
families = table.families()
for name, fdesc in families.iteritems():
assert_is_instance(name, basestring)
assert_is_instance(fdesc, dict)
assert_in('name', fdesc)
assert_in('max_versions', fdesc)
示例15: test_testprofile_group_manager_no_name_args_gt_one
def test_testprofile_group_manager_no_name_args_gt_one():
"""profile.TestProfile.group_manager: no name and len(args) > 1 is valid"""
prof = profile.TestProfile()
with prof.group_manager(utils.Test, 'foo') as g:
g(['a', 'b'])
nt.assert_in(grouptools.join('foo', 'a b'), prof.test_list)