【发布时间】:2018-08-15 19:25:15
【问题描述】:
所以我对编写单元测试非常陌生,我需要一些关于如何为我编写的课程编写单元测试的指导。 任何帮助将不胜感激 提前致谢!另外,我想在 pycharm 中编写单元测试。
class StringProcessor:
def __init__(self, yo="", a="", b="", f=""):
self.yo = yo
self.a = a
self.b = b
self.f = f
def my_first_test(self):
yo = input("Enter your string here")
ya = yo.split()
even = 0
odd = 0
for i in ya:
if len(i) % 2 == 0:
even = even + 1
else:
odd = odd + 1
print("The number of odd words are ", odd)
print("The number of even words are", even)
def my_second_test(self, a, b):
d = a.split()
print("The word", b, "is repeated: ", d.count(b), "times")
def my_third_test(self, f):
d = {}
lst = f.split()
for c in lst:
d[c] = lst.count(c)
for key,value in d.items():
print(key, ":", value)
【问题讨论】:
标签: python-3.x pycharm python-unittest