コード例 #1
0
    def test_bad_input(self):
        name_score_expe = [('Bob', 30, 30),  # new score
                           ('Bob', '', 30),  # input nothing
                           ('Bob', 'test', 30)]  # input string

        for name, score, expe in name_score_expe:
            observed = high_score(name, score)
            self.assertEqual(observed, expe,
                             "I'm looking for: " + str(expe) +
                             " but got:  " + str(observed))
コード例 #2
0
    def test_a_bunch(self):
        name_score_expe = [('Adam', 50, 50),  # new score
                           ('Adam', 60, 60),  # higher score
                           ('Adam', -10, 60),  # lower score
                           ('Fred', 0, 0)]  # new score for new player

        for name, score, expe in name_score_expe:
            observed = high_score(name, score)
            self.assertEqual(observed, expe,
                             "I'm looking for: " + str(expe) +
                             " but got:  " + str(observed))