一、使用anaconda搭建python环境
conda info --env 查看环境
conda remove -n web --all 删除环境
conda create --name python python=3.8 创建名为python的虚拟环境
# To activate this environment, use
$ conda activate python
# To deactivate an active environment, use
$ conda deactivate
二、pycharm新建工程,使用conda创建好的环境
三、引入unitest
python -m unittest -v TestMain.py
import unittest
class TestClass(object):
def add(self, x, y):
return x+y
def is_string(self, s):
return type(s) == str
class TestCases(unittest.TestCase):
def setUp(self) -> None:
self.test_class = TestClass()
def test_add_5_5(self):
self.assertEqual(self.test_class.add(5, 5), 10)
def test_bool_value(self):
self.assertTrue(self.test_class.is_string("5"))
def tearDown(self) -> None:
del self.test_class
if __name__ == '__main__':
unittest.main()
# 创建测试套件
# suit = unittest.TestSuite()
# suit.addTest([TestCases("test01"), TestCases("test02")])
# testrun = unittest.TextTestRunner()
# testrun.run(suit)
标签:--,self,class,python,conda,测试,test,unittest
From: https://www.cnblogs.com/logmagic/p/16608000.html