Pytest 停留在“收集...”

Kai*_*sar 10 python testing pytest pandas

我有一个文件new_script_piped.py,其中包含我想测试的函数:

def columns_preparation(df):

    df.COLUMN_1.replace({'-999':'don't consider'}, inplace=True)
    ...more lines

    return df
Run Code Online (Sandbox Code Playgroud)

和测试文件test_new_script_piped.py

import pandas as pd
import new_script_piped as x

def test_columns_preparation(df):
    
    test_df = pd.read_excel('test_column_preparation.xlsx')
    result_df = pd.read_excel('test_column_preparation_result.xlsx')

    assert x.columns_preparation(test_df) == result_df
Run Code Online (Sandbox Code Playgroud)

所有文件都位于同一目录中。我在命令行上尝试过:

python3 -m pytest new_script_piped.py
Run Code Online (Sandbox Code Playgroud)
pytest new_script_piped.py
Run Code Online (Sandbox Code Playgroud)
python -m pytest new_script_piped.py
Run Code Online (Sandbox Code Playgroud)

他们都被搞砸了:

platform darwin -- Python 3.7.3, pytest-4.5.0, py-1.8.0, pluggy-0.11.0
rootdir: /Users/31275553/Documents/
collecting ... 
Run Code Online (Sandbox Code Playgroud)

Dan*_*aun 9

您的测试可能需要很长时间

pytest -s path_to_script.py  
Run Code Online (Sandbox Code Playgroud)

为了查看标准输出是否有任何进度打印