返回 DeepSeek-Reasonix
test_invoice.py
1 import os
2 import sys
3 import unittest
4
5 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
6
7 from invoice import total
8
9
10 class TestInvoice(unittest.TestCase):
11 def test_single_item(self):
12 self.assertEqual(total([(19.99, 1)]), 19.99)
13
14 def test_repeated_item(self):
15 self.assertEqual(total([(19.99, 3)]), 59.97)
16
17 def test_mixed_cart(self):
18 self.assertEqual(total([(0.10, 3), (2.30, 1)]), 2.60)
19
20 def test_empty_cart(self):
21 self.assertEqual(total([]), 0)
22
23
24 if __name__ == "__main__":
25 unittest.main()
26
26 lines PYTHON