python - 通过 nose 或 pytest 在 Python 的单元测试中集成 argparse 脚本的建议

标签 python unit-testing argparse nose pytest

我的 recent project主要由一个 API 组成,我已经为 pytestnose 编写了一些单元测试。

我在这个包中有一些使用这个 API 的脚本,想知道是否有一种好的方法可以将它们包含在那些单元测试中。

会有 subprocess.call 方式,但我认为这很丑陋。您对我如何集成这些脚本有什么建议吗?

最佳答案

如果还没有用 python 重写你的脚本。只需将其导入您的测试即可。

关于python - 通过 nose 或 pytest 在 Python 的单元测试中集成 argparse 脚本的建议,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23975530/

相关文章:

python - 使用 assertRaise 测试异常消息

Python:如何处理argparse的异常?

Python argparse : "Dry run" flag that disable other flags using

python - 如何通过子进程将 argparse 中的 args 提供给外部程序调用

Python 将 ndarrays 转换为图形

python - 如何使用setuptools和类方法创建entry_points?

c# - 使用 Nunit 测试异常

python - 遍历元组列表的一个子集

python - django if user.is_authenticated 不工作但登录用户

c++ - 如何跳过 BOOST 单元测试?