本文整理汇总了Python中specter.expect函数的典型用法代码示例。如果您正苦于以下问题:Python expect函数的具体用法?Python expect怎么用?Python expect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了expect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: can_update
def can_update(self):
model = TestModel()
model.thing = 'bam'
model.update(thing='other')
expect(model.thing).to.equal('other')
示例2: should_take_into_account_conditional_probability
def should_take_into_account_conditional_probability(self):
user_tz = ['Eastern (US & Canada)', 'Pacific (US & Canada)']
l1_time = [9, 9]
l1_day = [0, 1]
l2_time = [9, 9]
l2_day = [3, 4]
l3_time = [None, 9]
l3_day = [None, 5]
schedule_type = [2, 3]
training_data = pd.DataFrame({ 'user_tz': user_tz,
'l1_time': l1_time,
'l1_day': l1_day,
'l2_time': l2_time,
'l2_day': l2_day,
'l3_time': l3_time,
'l3_day': l3_day,
'schedule_type': schedule_type
})
business_forecast = [{'schedule_type': 2,
'user_tz': 'Eastern (US & Canada)',
'frequency': 1 },
{'schedule_type': 3,
'user_tz': 'Pacific (US & Canada)',
'frequency': 2 }]
model = GeneralProbModel()
model.fit(training_data)
p = model.predict(business_forecast)
expect(True).to.equal(True)
示例3: handles_predicting_cases_it_has_not_seen_before
def handles_predicting_cases_it_has_not_seen_before(self):
user_tz = ['Eastern (US & Canada)', 'Pacific (US & Canada)']
l1_time = [9, 9]
l1_day = [0, 1]
l2_time = [9, 9]
l2_day = [3, 4]
l3_time = [None, 9]
l3_day = [None, 5]
schedule_type = [2, 3]
training_data = pd.DataFrame({ 'user_tz': user_tz,
'l1_time': l1_time,
'l1_day': l1_day,
'l2_time': l2_time,
'l2_day': l2_day,
'l3_time': l3_time,
'l3_day': l3_day,
'schedule_type': schedule_type
})
business_forecast = [{'schedule_type': 1,
'user_tz': 'Eastern (US & Canada)',
'frequency': 1 },
{'schedule_type': 4,
'user_tz': 'Pacific (US & Canada)',
'frequency': 2 }]
model = GeneralProbModel()
model.fit(training_data)
p = model.predict(business_forecast)
expect(True).to.equal(True)
示例4: transmute_to_and_from_with_custom_serializer
def transmute_to_and_from_with_custom_serializer(self):
mapping = TestWrappedModel()
mapping.test = "bam"
json_str = '{"#item": {"test": "bam"}}'
class Custom(object):
@classmethod
def dumps(cls, value):
value['#item']['test'] = 'allthethings'
return json.dumps(value)
@classmethod
def loads(cls, value):
loaded = json.loads(json_str)
loaded['#item']['test'] = 'magic'
return loaded
result = JsonTransmuter.transmute_to(
mapping,
encoder=Custom
)
expect(result).to.equal('{"#item": {"test": "allthethings"}}')
result = JsonTransmuter.transmute_from(
json_str,
TestWrappedModel,
decoder=Custom
)
expect(result.test).to.equal('magic')
示例5: can_delete_job
def can_delete_job(self):
post_resp = self._post_job()
job_id = post_resp.json['job_id']
resp = self.app.delete('/v1/tenant/jobs/{0}'.format(job_id),
expect_errors=True)
expect(resp.status_int).to.equal(200)
示例6: should_not_have_weird_hours
def should_not_have_weird_hours(self):
user_tz = ['Eastern (US & Canada)', 'Pacific (US & Canada)']
l1_time = [9, 9]
l2_time = [9, 9]
l3_time = [None, 9]
training_data = pd.DataFrame({ 'user_tz': user_tz,
'l1_time': l1_time,
'l2_time': l2_time
})
business_forecast = [{'schedule_type': 2,
'timezone': 'Eastern (US & Canada)',
'frequency': 1 },
{'schedule_type': 3,
'timezone': 'Pacific (US & Canada)',
'frequency': 2 }]
smart_heuristic_model = SmartHeuristicModel()
smart_heuristic_model.fit(training_data)
schedule = smart_heuristic_model.\
generate_sample_schedule(business_forecast)
_sum = schedule._table_df.sum().sum()
expect(_sum).to.equal(8)
示例7: cannot_be_instantiated
def cannot_be_instantiated(self):
try:
result = AbstractPlugin()
except TypeError:
# Expected
result = None
expect(result).to.be_none()
示例8: transmute_to_and_from_with_unknown_type
def transmute_to_and_from_with_unknown_type(self):
class CustomType(object):
def __init__(self, something):
self.something = something
class TestMappedModel(JsonMappedModel):
__mapping__ = {
'test': Attr('test', CustomType),
}
model = TestMappedModel()
model.test = CustomType('thing')
serialized = '{}'
result = JsonTransmuter.transmute_to(model)
expect(result).to.equal(serialized)
result = JsonTransmuter.transmute_from(
'{"test": {"something": "thing"}}',
TestMappedModel
)
attr = getattr(result, 'test', None)
expect(attr).to.be_none()
示例9: can_authenticate
def can_authenticate(self, post_func):
post_func.return_value = get_keystone_v2_auth_resp()
creds = self.auth.authenticate()
expect(creds.get('token', None)).to.equal('some_token')
expect(creds.get('project_id', None)).to.equal('some_tenant')
示例10: transmute_to_with_empty_submodel
def transmute_to_with_empty_submodel(self):
model = TestChildMapping()
model.child = None
result = JsonTransmuter.transmute_to(model, to_string=False)
expect(result.get('child')).to.be_none()
示例11: transmute_to_with_different_attr_naming
def transmute_to_with_different_attr_naming(self):
model = TestDifferentAttrNaming()
model.my_thing = 'something'
result = JsonTransmuter.transmute_to(model, to_string=False)
expect(result['my-thing']).to.equal('something')
示例12: can_authenticate
def can_authenticate(self, post_func):
r = get_keystone_v2_auth_resp()
post_func.return_value = r
self.auth(r)
expect(r.headers.get('X-Auth-Token')).to.equal('some_token')
expect(r.headers.get('X-Project-Id')).to.equal('some_tenant')
示例13: raises_exception_on_unsupported_provider
def raises_exception_on_unsupported_provider(self, get_target, get_driver):
target = self.TARGET_WITH_UNSUPPORTED_PROVIDER
driver_stub = self._get_libcloud_driver_stub([])
get_target.return_value = target
get_driver.return_value = driver_stub
expect(self.plugin.execute_action, [self.job, self.action]) \
.to.raise_a(Exception)
示例14: raises_exception_on_invalid_address
def raises_exception_on_invalid_address(self, get_target, get_driver):
target = self.TARGET_WITH_IP_ADDRESS
driver_stub = self._get_libcloud_driver_stub([])
get_target.return_value = target
get_driver.return_value = driver_stub
expect(self.plugin.execute_action, [self.job, self.action]) \
.to.raise_a(Exception)
示例15: run_requires_a_project_cfg
def run_requires_a_project_cfg(self):
config._config = None
try:
app.main(['run', 'bam'])
except SystemExit:
err_msg = 'Error: Could not file project configuration!'
expect(err_msg).to.be_in(self.stdout.getvalue())