我有同樣的問題,有兩種測試方法,這裏是主類的原始方法:如何解決錯誤:郵編參數#1必須支持迭代
def get_num_words(self, word_part):
""" 1 as default, may want 0 as an invalid case """
if word_part[3] == '0a':
self.num_words = 10
else:
self.num_words = int(word_part[3])
return self.num_words
def get_num_pointers(self, before_at):
self.num_pointers = int(before_at.split()[-1])
return self.num_pointers
而且這裏有兩個測試類:
def test_get_num_words(self):
word_part = ['13797906', '23', 'n', '04', 'flood', '0', 'inundation', '0', 'deluge', '0', 'torrent', '0', '005', '@', '13796604', 'n', '0000', '+', '00603894', 'a', '0401', '+', '00753137', 'v', '0302', '+', '01527311', 'v', '0203', '+', '02361703', 'v', '0101', '|', 'an', 'overwhelming', 'number', 'or', 'amount;', '"a', 'flood', 'of', 'requests";', '"a', 'torrent', 'of', 'abuse"']
expected = 04
real = self.wn.get_num_words(word_part)
for r, a in zip(real, expected):
self.assertEqual(r, a)
def test_get_num_pointers(self):
before_at = '13797906 23 n 04 flood 0 inundation 0 deluge 0 torrent 0 005'
expected = 5
real = self.wn.get_num_pointers(before_at)
for r, a in zip(real, expected):
self.assertEqual(r, a)
這是他們給了錯誤:TypeError: zip argument #1 must support iteration
該項目工程全面而這些都是在20周不同的測試不能正常工作的只有2次測試。