|
6 | 6 | from ..testing import assert_equal |
7 | 7 |
|
8 | 8 |
|
9 | | -def test_alternate_content_is_replaced_by_contents_of_fallback(): |
10 | | - xml_string = ( |
11 | | - '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' + |
12 | | - '<numbering xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">' + |
13 | | - '<mc:AlternateContent>' + |
14 | | - '<mc:Choice Requires="w14">' + |
15 | | - '<choice/>' + |
16 | | - '</mc:Choice>' + |
17 | | - '<mc:Fallback>' + |
18 | | - '<fallback/>' + |
19 | | - '</mc:Fallback>' + |
20 | | - '</mc:AlternateContent>' + |
21 | | - '</numbering>') |
22 | | - |
23 | | - result = office_xml.read(io.StringIO(xml_string)) |
24 | | - assert_equal([xml.element("fallback")], result.children) |
| 9 | +class AlternateContentTests(object): |
| 10 | + def test_when_fallback_is_present_then_fallback_is_read(self): |
| 11 | + xml_string = ( |
| 12 | + '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' + |
| 13 | + '<numbering xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">' + |
| 14 | + '<mc:AlternateContent>' + |
| 15 | + '<mc:Choice Requires="w14">' + |
| 16 | + '<choice/>' + |
| 17 | + '</mc:Choice>' + |
| 18 | + '<mc:Fallback>' + |
| 19 | + '<fallback/>' + |
| 20 | + '</mc:Fallback>' + |
| 21 | + '</mc:AlternateContent>' + |
| 22 | + '</numbering>') |
| 23 | + |
| 24 | + result = office_xml.read(io.StringIO(xml_string)) |
| 25 | + assert_equal([xml.element("fallback")], result.children) |
| 26 | + |
| 27 | + |
| 28 | + def test_when_fallback_is_not_present_then_element_is_ignored(self): |
| 29 | + xml_string = ( |
| 30 | + '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' + |
| 31 | + '<numbering xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">' + |
| 32 | + '<mc:AlternateContent>' + |
| 33 | + '<mc:Choice Requires="w14">' + |
| 34 | + '<choice/>' + |
| 35 | + '</mc:Choice>' + |
| 36 | + '</mc:AlternateContent>' + |
| 37 | + '</numbering>') |
| 38 | + |
| 39 | + result = office_xml.read(io.StringIO(xml_string)) |
| 40 | + assert_equal([], result.children) |
0 commit comments