def abn_abc(voteslist):
sums = {}
for vote in votes:
if vote in sums:
sums[vote] += 1
else:
sums[vote] = 1
return tally_ballots(sums)
如何为此功能编写单元测试?
def abn_abc(voteslist):
sums = {}
for vote in votes:
if vote in sums:
sums[vote] += 1
else:
sums[vote] = 1
return tally_ballots(sums)
如何为此功能编写单元测试?
像这样的东西:
import unittest
from wherever import abn_abc
class AbnAbcTest(unittest.TestCase):
def test_abn_abc(self):
list_for_testing with = [<insert list here>]
self.assertEqual(abn_abc(list_for_testing_with), <expected result>)
if __name__ == '__main__':
unittest.main()
这是文档。