1 在settings.json中添加如下
"python.testing.unittestArgs": [
"-v",
"-s",
"./",
"-p",
"*_test.py"
],
"python.testing.pytestEnabled": false,
"python.testing.unittestEnabled": true,
-s后的参数代表启动路径
-p 代表测试文件pattern
2 创建测试文件
as_test.py
注意函数名要以'test_'开头
import unittest
class TestStringMethods(unittest.TestCase):
def test_add(self):
a = 1
b = 2
self.assertEqual(a,1)
def test_upper(self):
# self.assertEqual('foo'.upper(), 'FOO')
print("here")
print("dasdasdwadawdwad")
def test_isupper(self):
self.as