本文整理汇总了Python中nose.tools.assert_is_none函数的典型用法代码示例。如果您正苦于以下问题:Python assert_is_none函数的具体用法?Python assert_is_none怎么用?Python assert_is_none使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_is_none函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_require_all
def test_require_all():
class DefaultInit(ValueObject):
id = Int()
name = Unicode()
obj = DefaultInit(1, "Dale")
obj = DefaultInit(name="Dale", id=1)
with nt.assert_raises(InvalidInitInvocation):
obj = DefaultInit()
class Loose(ValueObject):
__require_all__ = False
id = Int()
name = Unicode()
obj = Loose(1)
nt.assert_equal(obj.id, 1)
nt.assert_is_none(obj.name)
# still strict mutation
with nt.assert_raises(IllegalMutation):
obj.id = 3
# still won't accept extra args
with nt.assert_raises(InvalidInitInvocation):
Loose(1, "DALE", 123)
# no error
Loose()
示例2: test_get_engine
def test_get_engine(self):
self.ip.connected = False
e = self.ip.get_engine()
nt.assert_is_none(e)
self.ip.connected = True
e = self.ip.get_engine()
nt.assert_equal(self.sa_engine, e)
示例3: test_customer_bank_accounts_list
def test_customer_bank_accounts_list():
fixture = helpers.load_fixture('customer_bank_accounts')['list']
helpers.stub_response(fixture)
response = helpers.client.customer_bank_accounts.list(*fixture['url_params'])
body = fixture['body']['customer_bank_accounts']
assert_is_instance(response, list_response.ListResponse)
assert_is_instance(response.records[0], resources.CustomerBankAccount)
assert_equal(response.before, fixture['body']['meta']['cursors']['before'])
assert_equal(response.after, fixture['body']['meta']['cursors']['after'])
assert_is_none(responses.calls[-1].request.headers.get('Idempotency-Key'))
assert_equal([r.account_holder_name for r in response.records],
[b.get('account_holder_name') for b in body])
assert_equal([r.account_number_ending for r in response.records],
[b.get('account_number_ending') for b in body])
assert_equal([r.bank_name for r in response.records],
[b.get('bank_name') for b in body])
assert_equal([r.country_code for r in response.records],
[b.get('country_code') for b in body])
assert_equal([r.created_at for r in response.records],
[b.get('created_at') for b in body])
assert_equal([r.currency for r in response.records],
[b.get('currency') for b in body])
assert_equal([r.enabled for r in response.records],
[b.get('enabled') for b in body])
assert_equal([r.id for r in response.records],
[b.get('id') for b in body])
assert_equal([r.metadata for r in response.records],
[b.get('metadata') for b in body])
示例4: test_snapshot
def test_snapshot():
with tmp_db('snapshot') as db:
db.put(b'a', b'a')
db.put(b'b', b'b')
# Snapshot should have existing values, but not changed values
snapshot = db.snapshot()
assert_equal(b'a', snapshot.get(b'a'))
assert_list_equal(
[b'a', b'b'],
list(snapshot.iterator(include_value=False)))
assert_is_none(snapshot.get(b'c'))
db.delete(b'a')
db.put(b'c', b'c')
assert_is_none(snapshot.get(b'c'))
assert_list_equal(
[b'a', b'b'],
list(snapshot.iterator(include_value=False)))
# New snapshot should reflect latest state
snapshot = db.snapshot()
assert_equal(b'c', snapshot.get(b'c'))
assert_list_equal(
[b'b', b'c'],
list(snapshot.iterator(include_value=False)))
# Snapshots are directly iterable, just like DB
assert_list_equal(
[b'b', b'c'],
list(k for k, v in snapshot))
示例5: test_get_site_notification_impressions_over
def test_get_site_notification_impressions_over(self, request, response, SiteNotification):
note = SiteNotification.current.return_value
note._id = 'deadbeef'
note.impressions = 2
request.cookies = {'site-notification': 'deadbeef-3-false'}
assert_is_none(ThemeProvider().get_site_notification())
assert not response.set_cookie.called
示例6: test_mandates_list
def test_mandates_list():
fixture = helpers.load_fixture('mandates')['list']
helpers.stub_response(fixture)
response = helpers.client.mandates.list(*fixture['url_params'])
body = fixture['body']['mandates']
assert_is_instance(response, list_response.ListResponse)
assert_is_instance(response.records[0], resources.Mandate)
assert_equal(response.before, fixture['body']['meta']['cursors']['before'])
assert_equal(response.after, fixture['body']['meta']['cursors']['after'])
assert_is_none(responses.calls[-1].request.headers.get('Idempotency-Key'))
assert_equal([r.created_at for r in response.records],
[b.get('created_at') for b in body])
assert_equal([r.id for r in response.records],
[b.get('id') for b in body])
assert_equal([r.metadata for r in response.records],
[b.get('metadata') for b in body])
assert_equal([r.next_possible_charge_date for r in response.records],
[b.get('next_possible_charge_date') for b in body])
assert_equal([r.payments_require_approval for r in response.records],
[b.get('payments_require_approval') for b in body])
assert_equal([r.reference for r in response.records],
[b.get('reference') for b in body])
assert_equal([r.scheme for r in response.records],
[b.get('scheme') for b in body])
assert_equal([r.status for r in response.records],
[b.get('status') for b in body])
示例7: test_get_next_candidate
def test_get_next_candidate(self):
"""
Tests the get next candidate function.
Tests:
- The candidate's parameters are acceptable
"""
cand = None
counter = 0
while cand is None and counter < 20:
cand = self.EAss.get_next_candidate()
time.sleep(0.1)
counter += 1
if counter == 20:
raise Exception("Received no result in the first 2 seconds.")
assert_is_none(cand.result)
params = cand.params
assert_less_equal(params["x"], 1)
assert_greater_equal(params["x"], 0)
assert_in(params["name"], self.param_defs["name"].values)
self.EAss.update(cand, "pausing")
time.sleep(1)
new_cand = None
while new_cand is None and counter < 20:
new_cand = self.EAss.get_next_candidate()
time.sleep(0.1)
counter += 1
if counter == 20:
raise Exception("Received no result in the first 2 seconds.")
assert_equal(new_cand, cand)
示例8: test_LockingQueue_put_get
def test_LockingQueue_put_get(qbcli, app1, item1, item2):
nt.assert_false(qbcli.exists(app1))
# instantiating LockingQueue does not create any objects in backend
queue = qbcli.LockingQueue(app1)
nt.assert_equal(queue.size(), 0)
# fail if consuming before you've gotten anything
with nt.assert_raises(UserWarning):
queue.consume()
# get nothing from an empty queue (and don't fail!)
nt.assert_is_none(queue.get())
# put item in queue
nt.assert_equal(queue.size(), 0)
queue.put(item1)
queue.put(item2)
queue.put(item1)
nt.assert_equal(queue.size(), 3)
nt.assert_equal(queue.get(0), item1)
nt.assert_equal(queue.get(), item1)
# Multiple LockingQueue instances can address the same path
queue2 = qbcli.LockingQueue(app1)
nt.assert_equal(queue2.size(), 3)
nt.assert_equal(queue2.get(), item2)
nt.assert_equal(queue.get(), item1) # ensure not somehow mutable or linked
# cleanup
queue.consume()
queue2.consume()
示例9: test_reset_password
def test_reset_password(self, PasswordResetTokenGeneratorMock):
data = {
'email': self.user.email,
}
PasswordResetTokenGeneratorMock.return_value = 'abc'
response = self.client.post(
path=self.reset_password_url,
data=json.dumps(data),
content_type='application/json',
)
assert_equals(response.status_code, status.HTTP_201_CREATED)
assert_equals(len(mail.outbox), 1)
assert_equals(mail.outbox[0].subject, 'Reset Your Password')
data = {
'reset_token': 'abc',
'new_password': self.new_password,
'password_confirmation': self.new_password,
}
response = self.client.post(
path=self.reset_password_complete_url,
data=json.dumps(data),
content_type='application/json'
)
assert_equals(response.status_code, status.HTTP_200_OK)
assert_true(User.objects.get(pk=self.user.id).check_password(self.new_password))
assert_is_none(cache.get(self.user.email))
示例10: test_footer
def test_footer(self):
toc = [
navigation.NavItem(
url='/preamble/2016_02749/cfr_changes/478',
title=navigation.Title('Authority', '27 CFR 478', 'Authority'),
markup_id='2016_02749-cfr-478',
category='27 CFR 478'),
navigation.NavItem(
url='/preamble/2016_02749/cfr_changes/478-99',
title=navigation.Title(
'§ 478.99 Certain', '§ 478.99', 'Certain'),
markup_id='2016_02749-cfr-478-99',
category='27 CFR 478'),
navigation.NavItem(
url='/preamble/2016_02749/cfr_changes/478-120',
title=navigation.Title(
'§ 478.120 Firearms', '§ 478.120', 'Firearms'),
markup_id='2016_02749-cfr-478-120',
category='27 CFR 478')
]
nav = navigation.footer([], toc, '2016_02749-cfr-478')
assert_is_none(nav['previous'])
assert_equal(nav['next'].section_id, '2016_02749-cfr-478-99')
nav = navigation.footer([], toc, '2016_02749-cfr-478-99')
assert_equal(nav['previous'].section_id, '2016_02749-cfr-478')
assert_equal(nav['next'].section_id, '2016_02749-cfr-478-120')
nav = navigation.footer([], toc, '2016_02749-cfr-478-120')
assert_equal(nav['previous'].section_id, '2016_02749-cfr-478-99')
assert_is_none(nav['next'])
示例11: test_init
def test_init(self):
#test default parameters
exp = Experiment("test", {"x": MinMaxNumericParamDef(0, 1)})
opt = BayesianOptimizer(exp)
assert_equal(opt.initial_random_runs, 10)
assert_is_none(opt.acquisition_hyperparams)
assert_equal(opt.num_gp_restarts, 10)
assert_true(isinstance(opt.acquisition_function, ExpectedImprovement))
assert_dict_equal(opt.kernel_params, {})
assert_equal(opt.kernel, "matern52")
#test correct initialization
opt_arguments = {
"initial_random_runs": 5,
"acquisition_hyperparams": {},
"num_gp_restarts": 5,
"acquisition": ProbabilityOfImprovement,
"kernel_params": {},
"kernel": "matern52",
"mcmc": True,
}
opt = BayesianOptimizer(exp, opt_arguments)
assert_equal(opt.initial_random_runs, 5)
assert_dict_equal(opt.acquisition_hyperparams, {})
assert_equal(opt.num_gp_restarts, 5)
assert_true(isinstance(opt.acquisition_function, ProbabilityOfImprovement))
assert_dict_equal(opt.kernel_params, {})
assert_equal(opt.kernel, "matern52")
示例12: test_after_remove_authorized_user_not_self
def test_after_remove_authorized_user_not_self(self):
message = self.node_settings.after_remove_contributor(
self.node, self.user_settings.owner)
self.node_settings.save()
assert_is_none(self.node_settings.user_settings)
assert_true(message)
assert_in('You can re-authenticate', message)
示例13: test_get_credentials__provider_not_return_credentials
def test_get_credentials__provider_not_return_credentials(self):
self.cred_provider.get_synapse_credentials.return_value = None
creds = self.credential_provider_chain.get_credentials(syn, self.user_login_args)
assert_is_none(creds)
self.cred_provider.get_synapse_credentials.assert_called_once_with(syn, self.user_login_args)
示例14: test_construct_factory_from_form
def test_construct_factory_from_form():
form_factory = construct_factory_from_form(DjangoTestForm)
assert_true(issubclass(form_factory, FormFactory))
assert_equal(form_factory._meta.form, DjangoTestForm)
assert_is_none(form_factory._meta.fields)
assert_is_none(form_factory._meta.exclude)
assert_equal(form_factory._meta.settings, {})
示例15: test_no_score
def test_no_score(self):
models.StateNameVoter.items.create(
state_lname_fname="PA_APP_GERRY",
persuasion_score='1.2',
)
bulk_impute([self.user], 'gotv_score')
tools.assert_is_none(self.user.gotv_score)