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
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)
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)
def test_article_success(self): dn = 'index' yaml = 'weight: 20' props: BaseArticleModel = load_model(dn, BaseArticleModel, yaml) assert 20 == props.weight