(self)
| 818 | ) |
| 819 | |
| 820 | def test_indent_level(self): |
| 821 | elem = ET.XML("<html><body><p>pre<br/>post</p><p>text</p></body></html>") |
| 822 | with self.assertRaises(ValueError): |
| 823 | ET.indent(elem, level=-1) |
| 824 | self.assertEqual( |
| 825 | ET.tostring(elem), |
| 826 | b"<html><body><p>pre<br />post</p><p>text</p></body></html>" |
| 827 | ) |
| 828 | |
| 829 | ET.indent(elem, level=2) |
| 830 | self.assertEqual( |
| 831 | ET.tostring(elem), |
| 832 | b'<html>\n' |
| 833 | b' <body>\n' |
| 834 | b' <p>pre<br />post</p>\n' |
| 835 | b' <p>text</p>\n' |
| 836 | b' </body>\n' |
| 837 | b' </html>' |
| 838 | ) |
| 839 | |
| 840 | elem = ET.XML("<html><body><p>pre<br/>post</p><p>text</p></body></html>") |
| 841 | ET.indent(elem, level=1, space=' ') |
| 842 | self.assertEqual( |
| 843 | ET.tostring(elem), |
| 844 | b'<html>\n' |
| 845 | b' <body>\n' |
| 846 | b' <p>pre<br />post</p>\n' |
| 847 | b' <p>text</p>\n' |
| 848 | b' </body>\n' |
| 849 | b' </html>' |
| 850 | ) |
| 851 | |
| 852 | def test_tostring_default_namespace(self): |
| 853 | elem = ET.XML('<body xmlns="http://effbot.org/ns"><tag/></body>') |
nothing calls this directly
no test coverage detected