Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.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
Dataframe 断言Pytest的两个数据帧不相等_Dataframe_Try Catch_Pytest_Assert - Fatal编程技术网

Dataframe 断言Pytest的两个数据帧不相等

Dataframe 断言Pytest的两个数据帧不相等,dataframe,try-catch,pytest,assert,Dataframe,Try Catch,Pytest,Assert,我看了另一个人的问题,我试图问更多的问题,我试图找出为什么这不起作用 **@pytest.mark.parametrize("test_input_1, expected_outcome", [ (diag_config["clinical_input"]["code_tbl"], init_cohorts.get_clinical_code(diag_config["clinical_input"]["code_tbl"])) ]) def te

我看了另一个人的问题,我试图问更多的问题,我试图找出为什么这不起作用

 **@pytest.mark.parametrize("test_input_1, expected_outcome",
   [
       (diag_config["clinical_input"]["code_tbl"],
        init_cohorts.get_clinical_code(diag_config["clinical_input"]["code_tbl"]))

   ])  def test_get_clinical_code_fail(test_input_1, expected_outcome):
try:
    result = init_cohorts.get_clinical_code(test_input_1)
    expected_outcome = init_cohorts.get_clinical_code(diag_config["clinical_input"]["prov_tbl"])
    pd.testing.assert_frame_equal(result.toPandas(), expected_outcome.toPandas())
except AssertionError:
    # frames are not equal
    pass
else:
    # frames are equal
    raise AssertionError**
我根据的是这个

def assert_frame_not_equal(*args, **kwargs):
try:
    assert_frame_equal(*args, **kwargs)
except AssertionError:
    # frames are not equal
    pass
else:
    # frames are equal
    raise AssertionError

我得到了这个关键错误,尽管我应该得到这个try-catch应该得到的断言错误。

你能把这个错误添加到问题中吗?test\u-input\u-1='icd'expected\u-output=DataFrame@pytest.mark.parametize(“test\u-input\u-1,expected\u-output”def test\u-get\u-clinical\u-code\u-fail(test\u-input\u-1,expected\u-output):try:result=init_队列。get_clinical_code(test_input_1)>expected_outcome=init_队列。get_clinical_code(diag_config[“clinical_input”][“prov_tbl”])clinical_input=“provider”def get_clinical_code(self,clinical_input):>tbl=self.courts_config.clinical_input[临床_input]E KeyError:'provider'主要错误是E KeyError:'provider',因为当我对代码表值为'ICD'进行工作测试时,如果我将其更改为prov,预计它会失败,我会得到'provider';而系统没有正确处理它