示例#1
0
    def __init__(self, docname: str, rtype: str, yaml_content: str):
        self.docname = docname
        self.rtype = rtype
        self.parent = parse_parent(docname)

        model = self.__annotations__['props']
        self.props = load_model(docname, model, yaml_content)
def image_model():
    yaml = """
    usage: teaser
    filename: img.png
            """
    im: ImageModel = load_model('somedoc', ImageModel, yaml)

    yield im
示例#3
0
    def __init__(self,
                 docname: str,
                 wtype: str,
                 yaml_content: str,
                 rst_content: str = None):
        self.docname = docname
        self.wtype = wtype
        model = self.__annotations__['props']
        self.props: BaseWidgetModel = load_model(docname, model, yaml_content)

        if rst_content:
            self.content = rst_to_html(rst_content)
示例#4
0
 def test_article_extra(self):
     dn = 'index'
     yaml = 'flag: 9'
     with pytest.raises(SphinxError) as excinfo:
         load_model(dn, BaseWidgetModel, yaml)
     assert 'Validation error in docname index' in str(excinfo.value)
示例#5
0
 def test_article_success(self):
     dn = 'index'
     yaml = 'weight: 20'
     props: BaseArticleModel = load_model(dn, BaseArticleModel, yaml)
     assert 20 == props.weight