Python nosetests没有检测到本应失败的testcase
我正在尝试运行我的第一个python测试。然而,鼻测试并没有检测到错误值,而是总是通过它Python nosetests没有检测到本应失败的testcase,python,Python,我正在尝试运行我的第一个python测试。然而,鼻测试并没有检测到错误值,而是总是通过它 #!/usr/bin/env python import MySQLdb import xml.etree.cElementTree as ET def testCase9p(): # Open database: qa, and report connection db1 = MySQLdb.connect("host1","usr1","passwd1","db1" ) db
#!/usr/bin/env python
import MySQLdb
import xml.etree.cElementTree as ET
def testCase9p():
# Open database: qa, and report connection
db1 = MySQLdb.connect("host1","usr1","passwd1","db1" )
db2 = MySQLdb.connect("host","usr2","passwd2","db2" )
# prepare a cursor object using cursor() method
query1 = db1.cursor()
query2 = db2.cursor()
query1.execute("select modified from dcp where jobid =7;")
query2.execute("Select modified from jusage where jobid =7")
# Fetch a single row using fetchone() method.
data1 = query1.fetchone()
data2 = query2.fetchone()
if (data1 == data2):
field1.text = "Pass"
return True
else:
field1.text = "Fail"
return False
db1.close()
db2.close()
result=testCase9p()
#
#
然后,我运行了“使用xunit的鼻测试”,但结果并没有检测到它应该失败。
(我从后端知道它们不应该进行比较,我在哪里做得不正确?NoTests正在查找失败的代码。请尝试更改以下代码位
if (data1 == data2):
field1.text = "Pass"
return True
else:
field1.text = "Fail"
return False
到
assert data1 == data2