def test_create_variable_get(self): variable_get = odf_create_variable_get(u'你好 Zoé', value=42) expected = ('<text:variable-get text:name="%s" ' 'office:value-type="float" office:value="42">' '42' '</text:variable-get>') % convert_unicode(u'你好 Zoé') self.assertEqual(variable_get.serialize(), expected)
def test_create_variable_get(self): variable_get = odf_create_variable_get('你好 Zoé', value=42) expected = ('<text:variable-get text:name="%s" ' 'office:value-type="float" office:value="42">' '42' '</text:variable-get>') % convert_unicode('你好 Zoé') self.assertEqual(variable_get.serialize(), expected)
# Insert heading = odf_create_heading(1, text=u'A variable') body.append(heading) decl = body.get_variable_decls() decl.append(variable_decl) text = u'Set of spam.' paragraph = odf_create_paragraph(text, style=u"Standard") body.append(paragraph) paragraph._insert_between(variable_set, u"Set", u"spam.") text = u'The value of spam is: ' value = body.get_variable_set_value('spam') variable_get = odf_create_variable_get('spam', value) paragraph = odf_create_paragraph(text, style=u"Standard") body.append(paragraph) paragraph.insert_variable(variable_get, u"is: ") # 7- An user field # ---------------- # An user field "pi5" with the value 3.14159 user_field_decl = odf_create_user_field_decl('pi5', value=3.14159) # Insert heading = odf_create_heading(1, text=u'An user field') body.append(heading) decl = body.get_user_field_decls()
# Insert heading = odf_create_heading(1, text=u'A variable') body.append(heading) decl = body.get_variable_decls() decl.append(variable_decl) text = u'Set of spam.' paragraph = odf_create_paragraph(text, style=u"Standard") body.append(paragraph) paragraph._insert_between(variable_set, u"Set", u"spam.") text = u'The value of spam is: ' value = body.get_variable_set_value('spam') variable_get = odf_create_variable_get('spam', value) paragraph = odf_create_paragraph(text, style=u"Standard") body.append(paragraph) paragraph.insert_variable(variable_get, u"is: ") # 5- An user field # ---------------- # An user field "pi5" with the value 3.14159 user_field_decl = odf_create_user_field_decl('pi5', value=3.14159) # Insert heading = odf_create_heading(1, text=u'An user field') body.append(heading)