问题描述
这些是预测的测试方法
def test_get_prediction(input_params,output_params):
exec_log.info("Testing started for prediction")
response = aiservice.get_prediction(input_params)
assert response['predicted_label'] != None
test_insight(response)
def test_insight(response):
if('featureImportance' in response['Insight']):
data_table = response['Insight']['featureImportance']['data']
assert len(data_table) > 0
elif(response['Insight'] == 'nearestNeighbors'):
data_dict = response['Insight']['nearestNeighbors']
assert len(data_dict) > 0
elif('modelCoefficients' in response['Insight'] ):
data_table = response['Insight']['modelCoefficients ']['data']
assert len(data_table) > 0
当我在 vs 代码中使用 pytest 进行测试时总是给出错误
================================== FAILURES ===================================
_______________ test_workflow[Classification: Credit Approval] ________________
caplog = <_pytest.logging.LogCaptureFixture object at 0x0000026B1EF15EE0>
test_name = 'Classification: Credit Approval'
test_params = [{'dataimport': {'expectedOutput': {'result': 'success'},'input': {'file_location': 'AWS','test_filename': 'credit_d...': 3,'yAxisLabel': 'Debt',...},'input': {'Age': 30,'BankCustomer':
'g','Citizen': 'g','Creditscore': '1',...}}}]
@pytest.mark.parametrize("test_name,test_params",TEST_ParaMS.items(),ids=list(TEST_ParaMS.keys()))
def test_workflow(caplog,test_name,test_params):
response = login()
ai_service = create_ai_service()
assert response == True
assert len(ai_service) > 0
problem_type = ''
exec_log.info("testing started for " + test_name)
for stage in test_params:
for test_key,test_val in stage.items():
if(test_key == 'dataimport'):
test_upload_and_import_data(test_val['input'],test_val['expectedOutput'])
elif(test_key == 'featureEngineering'):
problem_type = test_feature_eng(test_val['input'],test_val['expectedOutput'])
elif(test_key == 'training'):
test_training(test_val['input'],test_val['expectedOutput'],problem_type)
elif(test_key == "askAI"):
> test_get_prediction(test_val['input'],test_val['expectedOutput'])
tests\test_pytest.py:87:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
input_params = {'Age': '30.83','BankCustomer': 'g',...}
output_params = {'insight': 'featureImportance'}
@allure.step
def test_get_prediction(input_params,output_params):
exec_log.info("Testing started for prediction")
response = aiservice.get_prediction(input_params)
> assert response['predicted_label'] != None
E assert None != None
tests\test_pytest.py:210: AssertionError
这总是给出预测结果
{'statusCode': 400,'body': '{"predicted_label": null,"Message": "您尝试访问的网址不接受请求,请检查导航器提供的网址"}','headers': {'Content-Type': 'application/json','Access-Control-Allow-Origin': '*'}}
我需要 'statusCode': 'Completed','body': '{"predicted_label": "+" ........
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)