Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python nosetests没有检测到本应失败的testcase_Python - Fatal编程技术网

Python nosetests没有检测到本应失败的testcase

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

我正在尝试运行我的第一个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" )
    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