GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — code_snippets/Python-Unit-Testing/test_calc.py at master · wkemmachat/code_snippets

Expand file tree

/

test_calc.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
33 lines (24 loc) · 941 Bytes
/

test_calc.py

Copy path

File metadata and controls

33 lines (24 loc) · 941 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import unittest
import calc
class TestCalc(unittest.TestCase):
def test_add(self):
self.assertEqual(calc.add(10, 5), 15)
self.assertEqual(calc.add(-1, 1), 0)
self.assertEqual(calc.add(-1, -1), -2)
def test_subtract(self):
self.assertEqual(calc.subtract(10, 5), 5)
self.assertEqual(calc.subtract(-1, 1), -2)
self.assertEqual(calc.subtract(-1, -1), 0)
def test_multiply(self):
self.assertEqual(calc.multiply(10, 5), 50)
self.assertEqual(calc.multiply(-1, 1), -1)
self.assertEqual(calc.multiply(-1, -1), 1)
def test_divide(self):
self.assertEqual(calc.divide(10, 5), 2)
self.assertEqual(calc.divide(-1, 1), -1)
self.assertEqual(calc.divide(-1, -1), 1)
self.assertEqual(calc.divide(5, 2), 2.5)
with self.assertRaises(ValueError):
calc.divide(10, 0)
if __name__ == '__main__':
unittest.main()
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.