sphinx Autodoc使用模块中的函数进行模拟

时间:2016-11-03 09:41:42

标签: python mocking python-sphinx autodoc

我最近开始使用sphinx autodoc进行文档编制。

我有一个导入

from wtforms import StringField, IntegerField, SelectField, BooleanField

在项目中,所以我最终嘲笑wtforms

但是在同一个文件中,我有一个在类变量中使用IntegerField的类,如下所示

class DbEditableForm(Form):
    data_version = IntegerField('data_version', validators=[Required()], widget=HiddenInput())

在导入DbEditableForm的文件中使用autodoc

我收到了关注错误

/home/ninad/third_year/balrog/docs/source/admin_api.rst:5: WARNING: autodoc: failed to import class u'SingleRuleView' from module u'auslib.admin.views.rules'; the following exception was raised:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/sphinx/ext/autodoc.py", line 519, in import_object
    __import__(self.modname)
  File "/home/ninad/third_year/balrog/auslib/admin/views/rules.py", line 12, in <module>
    from auslib.admin.views.forms import EditRuleForm, RuleForm, DbEditableForm, \
  File "/home/ninad/third_year/balrog/auslib/admin/views/forms.py", line 138, in <module>
    class DbEditableForm(Form):
  File "/home/ninad/third_year/balrog/auslib/admin/views/forms.py", line 142, in DbEditableForm
    data_version = IntegerField('data_version', validators=[Required()], widget=HiddenInput())
TypeError: object() takes no parameters

任何想法如何将autodoc用于导入DbEditableForm的文件?

0 个答案:

没有答案