python - 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
解决方案
您的测试可能需要很长时间
pytest -s path_to_script.py
如果您有任何进度打印,以便查看标准输出
推荐阅读
- excel - 即使结果为空白,当我将公式复制并粘贴为值时,Excel 也可能会插入隐藏字符 - 我该如何避免?
- php - 从多个函数中访问数据
- css - 如何在闪亮进度条的详细信息中添加换行符?
- javascript - Fetch API POST 请求响应返回空文本
- c++ - 如何在单独的源文件中定义模板函数并调用它,只包括标题
- ios - 类型不符合协议“可编码”
- konvajs - 向 Konva 形状添加描边而不增加其大小
- javascript - javascript scrollIntoView 函数在我的全局事件侦听器中不起作用
- javascript - 如何将 DOM 数据转换为 json
- html - 圆形元素上的框阴影