Castle: The best Real-Time/Embedded/HighTech language EVER. Attempt 2
修订版 | 5821f8fe1033bf16ee34a3b26f17d5bd53a688a2 (tree) |
---|---|
时间 | 2022-02-12 06:21:13 |
作者 | Albert Mietus < albert AT mietus DOT nl > |
Commiter | Albert Mietus < albert AT mietus DOT nl > |
refactored a bit
@@ -20,11 +20,13 @@ | ||
20 | 20 | assert_xml_Element(txt, tag='.//RegExpTerm', value=self.v3) |
21 | 21 | |
22 | 22 | |
23 | -def assert_xml_Element(txt, tag, version="0.0", child_count=None, **attribs,): | |
23 | +def assert_xml_Element(txt, tag, version="0.0", child_count=None, **attribs): | |
24 | 24 | """Partially verify an xml-string; focusing on 'tag' -- a real tag, or a (limited) XPATH-expression. |
25 | 25 | |
26 | 26 | This `tag` (expression) should result in a single hit!. *Use e.g `[0]` as suffix to select one from a list*. |
27 | - Pass ``key=value`` **attribs** to verify the found tag has those attribs and values.""" | |
27 | + | |
28 | + Pass ``key=value`` **attribs** to verify the found tag has those attribs and values. | |
29 | + Optionally, pass `child_count=INT` to verify the specified (single) tag has that number of children.""" | |
28 | 30 | |
29 | 31 | tree = ET.fromstring(txt) |
30 | 32 | if version: |
@@ -34,10 +36,8 @@ | ||
34 | 36 | assert len(founds) == 1, f"Expected only one element; got: {len(founds)} :{founds}" |
35 | 37 | |
36 | 38 | found = founds[0] |
37 | - logger.debug(f'XXX1 tag={tag}:: found={found}') | |
38 | 39 | |
39 | 40 | for attrib, value in attribs.items(): |
40 | - logger.debug(f'XXX2 tag={tag}:: attrib={attrib}, value={value}') | |
41 | 41 | assert found.attrib[attrib] == value |
42 | 42 | |
43 | 43 | if child_count: |