文件ceshilei.py:
class Shou_ji():
def __init__(self,wenti):
self.wenti=wenti
self.da=[]
def shou_wenti(self):
print(self.wenti)
def cun_wenti(self,huIDA):
self.da.append(huida)
def show_huida(self):
print('shou ji da ode an an shi :')
for daan in self.da:
print('-'+daan)
测试文件:
import unittest
from ceshilei import Shou_ji
class TestShouji(unittest.TestCase):
def ceshi_dan(self):
wenti='ni zui xi huan de shui guo?'
shuiguo=Shou_ji(wenti)
shuiguo.cun_wenti('pingguo')
self.assertIn('pingguo',shuiguo.da)
def ceshi_duo(self):
wenti='ni zui xi huan de shui guo ?'
shuiguo=Shou_ji(wenti)
da=['pingguo','putao','zhima']
for daan in da:
shuiguo.cun_wenti(daan)
for daan in da:
self.assertIn(daan,shuiguo,da)
unittest.main()
为什么运行结果是不能测试