示例#1
0
def test_manual_converter_2():
    s = setup_state(
        stu_code="my_array = np.array([[0,0], [0,0], [0,0]])",
        sol_code="my_array = np.array([[1,2], [3,4], [5,6]])",
        pec="import numpy as np",
    )
    set_converter(key="numpy.ndarray", fundef=lambda x: x.shape)
    s.check_object("my_array").has_equal_value()
示例#2
0
def test_manual_converter():
    res = helper.run(
        {
            "DC_CODE": "xl = pd.ExcelFile('battledeath2.xlsx')",
            "DC_SOLUTION": "xl = pd.ExcelFile('battledeath.xlsx')",
            "DC_PEC": "import pandas as pd; from urllib.request import urlretrieve; urlretrieve('https://s3.amazonaws.com/assets.datacamp.com/production/course_998/datasets/battledeath.xlsx', 'battledeath.xlsx'); from urllib.request import urlretrieve; urlretrieve('https://s3.amazonaws.com/assets.datacamp.com/production/course_998/datasets/battledeath.xlsx', 'battledeath2.xlsx')",
            "DC_SCT": """
def my_converter(x): return(x.sheet_names)
set_converter(key = "pandas.io.excel.ExcelFile", fundef = my_converter)
Ex().check_object('xl').has_equal_value()
""",
        }
    )
    assert res["correct"]