! /usr/bin/python
-- coding:utf-8 --
from lunwen import Foo #Foo是在lunwen中定义好的类
import unittest
import numpy as np
class TestStudent(unittest.TestCase):
def setUp(self):
self.foo = Foo()
self.dataset = np.loadtxt("demo_train", delimiter=',')
def tearDown(self):
self.foo = None
#通过
def test_computeDistance(self):
result = self.foo.computeDistance([-0.64199,-0.63819,-0.63826], self.dataset)
print(result)
self.assertEqual(1, 1)
def test_rand_score(self):
result = self.foo.rand_score([1,0,0,1,2],[1,0,0,1,2])
self.assertEqual(1, 1)
运行单元测试
if name == ‘main‘:
unittest.main()
原文地址:https://www.cnblogs.com/cccccttttyyy/p/12217247.html
时间: 2024-10-09 09:51:02