数学.py
def add(x, y=4):
return x + y
test_math.py
import unittest
import math
class TestMath(unittest.TestCase):
def test_add(self):
result = math.add(5, 7)
self.assertEqual(result, 12)
数学.py
def add(x, y=4):
return x + y
test_math.py
import unittest
import math
class TestMath(unittest.TestCase):
def test_add(self):
result = math.add(5, 7)
self.assertEqual(result, 12)
模块
math是一个标准模块Python,它将代替您的math.py.math.py例如,重命名为math_.py. 而且,是的,直接在中设置变量的值不是很正确def:最好这样做: