我正在为自己制作的类创建单元测试,如下所示:
import unittest
import dask.dataframe as dd
from my_class import MyClass
def test_nan():
# Drop_Nans
my_instance = MyClass(df,['foo'])
my_instance.first_method()
assert my_instance.df.compute().shape == (100, 4), "Should be (100, 4)"
if __name__ == "__main__":
df = dd.read_csv("dummy_data.csv",assume_missing=True)
test_nan()
但是这些看起来太冗长,是否可以在不为每个实例创建新实例的情况下测试这些方法?