将 pytest conftest.py 与单元测试混合:Typeerror

问题描述

我的conftest.py

<ScrollViewer Width=300 Height=200
   ScrollViewer.CanContentScroll="True"
   ScrollViewer.VerticalScrollVisibility="Auto"
   <ItemsControl
     ItemsSource="{Binding ItemsList}"
     Visibility="{Binding HmiState,Converter={StaticResource IsHmiViewState}}">
     <ItemsControl.ItemsContainerStyle>
       <Style>
         <Setter Property="FrameworkElement.Margin" Value="5" />
       </Style>
     </ItemsControl.ItemsContainerStyle>
     <ItemsControl.ItemsPanel>
       <ItemsPanelTemplate>
         <WrapPanel ItemsHost="True"/>
       </ItemsPanelTemplate>
     </ItemsControl.ItemsPanel>
   </ItemsControl>
</ScrollViewer>

test.py

@pytest.fixture(scope="class")
def prepare_test_dataframe():
    try:
        with pd.ExcelFile(TEST_INPUT_DIR + TEST_FILE_NAME) as xls:
            for sheet_name in xls.sheet_names:
                if sheet_name == "TESTSHEET1":
                    test_df = pd.read_excel(TEST_INPUT_DIR + TEST_FILE_NAME,sheet_name=sheet_name,header=None)
    except IOError:
        print("Cannot open file")

    return test_df

追溯:

@pytest.mark.usefixtures("prepare_test_dataframe")
class TestConvertXLS_Scad(unittest.TestCase):
    def test_add_units_columns(self,prepare_test_dataframe):
        test_merged_cells = [[1,37,1,43],[1,35,36]]
        test_df = prepare_test_dataframe
        actual_df = self.mymod.add_units_columns(test_df,test_merged_cells)

        # compare results
        self.assertEqual(actual_df.loc[32,"A"],2.0)

我一直在阅读其他帖子和 documents,但我似乎无法解决此问题。我哪里出错了?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)