~就很氣人,記錄下這個報錯,英語不好真坑~
(一)問題:must be equal to the number of values (0):
['countryCode', 'page_index', 'page_size', 'status', 'area'] must be equal to the number of values (0): []
(二)原因:pytest框架使用的csv文件,csv文件里有嚴格意義的行數控制,出現空格/空行導致!
(三)代碼描述:
import allure import pytest from common.csv_data_reader import read_csv_data from model.factory import InterfaceCenter data1 = read_csv_data('homepageNew_countryCode.csv') @allure.feature('HomepageNewAPI') class BaseAthenaSystemAPI(object): def setup_class(self): self.api = InterfaceCenter.get_interface() def teardown_class(self): del self.api # 編寫一個用例,新人頁接口用例編寫,能夠返回1/2頁數據,返回視頻不為空 # 新人頁接口返回的視頻相關數據,必要的節點屬性值不為空 class TestAthenaSystemAPI(BaseAthenaSystemAPI): def test_create_room(self): pass @allure.step('test_homepageNew_api') @pytest.mark.XXXX @pytest.mark.parametrize('countryCode,page_index,page_size,status,area', data1) def test_homepageNew_api(self,countryCode,page_index,page_size,status,area): ret = self.api.homepageNew_live_get(countryCode=countryCode,page_index=page_index,page_size=page_size) print(ret) # 判斷接口響應成功 assert ret.status == status roomsinfo = ret.data.video_info for info in roomsinfo: # 判斷視頻列表,不能為空 assert info.videosource is not None assert info.hlsvideosource is not None # 判斷是否是本大區的主播視頻 assert info.area == area # 判斷必要節點屬性不為空 for nesessary_key in [info.anchor_level, info.uface, info.uname, info.heat, info.vid, info.isTCLine]: assert nesessary_key != '' assert bool(nesessary_key) is True def teardown_method(self): pass if __name__ == '__main__': pytest.main(['./homepage_new/test_homepageNew.py'])