首页 > 解决方案 > Pytest 坚持“收集...”

问题描述

我有一个文件new_script_piped.py,其中包含要测试的功能:

def columns_preparation(df):

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

    return df

和测试文件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

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

python3 -m pytest new_script_piped.py
pytest new_script_piped.py
python -m pytest new_script_piped.py

他们都讨厌:

platform darwin -- Python 3.7.3, pytest-4.5.0, py-1.8.0, pluggy-0.11.0
rootdir: /Users/31275553/Documents/
collecting ... 

其他解决方案建议检查拼写错误并确保所有文件都在同一个文件夹中,但我已经遵守了。我的python解释器是:/.conda/envs/untitled/bin/python

标签: pythonpandastestingpytest

解决方案


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

pytest -s path_to_script.py  

如果您有任何进度打印,以便查看标准输出


推荐阅读