-1
def abn_abc(voteslist):
    sums = {}
    for vote in votes:
        if vote in sums:
            sums[vote] += 1  
        else:
            sums[vote] = 1
    return tally_ballots(sums)

如何为此功能编写单元测试?

4

1 回答 1

1

像这样的东西:

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()

这是文档

于 2012-12-04T05:34:07.417 回答