File: test_annotation_base.py

package info (click to toggle)
python-xsdata 24.1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,936 kB
  • sloc: python: 29,257; xml: 404; makefile: 27; sh: 6
file content (37 lines) | stat: -rw-r--r-- 1,352 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from unittest import TestCase

from xsdata.formats.dataclass.models.generics import AnyElement
from xsdata.models.xsd import Annotation, AnnotationBase, Documentation


class AnnotationBaseTest(TestCase):
    def test_property_dispaly_help(self):
        base = AnnotationBase()
        self.assertIsNone(base.display_help)

        base.annotations.append(Annotation(documentations=[Documentation()]))
        self.assertIsNone(base.display_help)

        base.annotations.append(
            Annotation(
                documentations=[
                    Documentation(
                        elements=[
                            "    I am a ",
                            AnyElement(
                                qname="{http://www.w3.org/1999/xhtml}p",
                                text="test",
                                tail="\n",
                                children=[
                                    AnyElement(
                                        qname="{http://www.w3.org/1999/xhtml}span",
                                        text="!",
                                    )
                                ],
                            ),
                        ]
                    )
                ]
            )
        )
        self.assertEqual("I am a <p>test<span>!</span></p>", base.display_help)