python - 是否可以使用 "manage.py test"在 Django 中运行单个 doctest

标签 python django doctest

在我的 Django 应用程序中,我混合了 doctests(在 models.py 和 views.py 中定义)和单元测试(在 tests.py 中定义。我可以通过以下方式调用单个单元测试:

manage.py test app.TestCase

但是,这似乎不适用于 doctests。有什么方法可以运行单个 doctest(在 models.py 或 views.py 中定义)?

最佳答案

我认为 python doctests 的工作方式是简单地在同一个解释器实例中运行模块中的所有 doctests。

我怀疑 manage.py 能否改变 python 文档测试的基本行为。

关于python - 是否可以使用 "manage.py test"在 Django 中运行单个 doctest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1657442/

相关文章:

python - Convert_obj_two.py 语法错误

python - Python 的 Matlab findpeaks 算法

html - 如果未选择任何选项,带有 ModelChoiceField(required=True) 的表单不会引发 ValidationError

python - 在 python 程序中使用 doctest 和登录

Python Networkx 权重标签定位

python - 在 python 中没有空格的拆分句子(nltk?)

python - Django 检查表单是否有效()

django - 我可以重定向到 django TemplateView 中的另一个 url 吗?

python doctest失败错误

python doctest : expected result is the same as the "got" result but the test failed