【python】must be equal to the number of values (0):!!!

~就很气人,记录下这个报错,英语不好真坑~

(一)问题: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'])
原文地址:https://www.cnblogs.com/darlingmz/p/13304205.html