def _test_string(self, xml): source = ETSource(xml) with source as src: assert_equals(src.read().decode('UTF-8'), xml) self._verify_string_representation(source, '<in-memory file>') assert_true(source._opened.closed) with ETSource(xml) as src: assert_equals(ET.parse(src).getroot().tag, 'tag')
def _test_string(self, xml, encoding='UTF-8'): source = ETSource(xml) with source as src: content = src.read() expected = xml if isinstance(xml, bytes) else xml.encode(encoding) assert_equal(content, expected) self._verify_string_representation(source, '<in-memory file>') assert_true(source._opened.closed) with ETSource(xml) as src: assert_equal(ET.parse(src).getroot().tag, 'tag')
def _test_string(self, xml): source = ETSource(xml) with source as src: content = src.read() if not IRONPYTHON: content = content.decode('UTF-8') assert_equal(content, xml) self._verify_string_representation(source, '<in-memory file>') assert_true(source._opened.closed) with ETSource(xml) as src: assert_equal(ET.parse(src).getroot().tag, 'tag')
def _test_string(self, xml): source = ETSource(xml) with source as src: content = src.read() if not IRONPYTHON_WITH_BROKEN_ETREE: content = content.decode('UTF-8') assert_equal(content, xml) self._verify_string_representation(source, '<in-memory file>') assert_true(source._opened.closed) with ETSource(xml) as src: assert_equal(ET.parse(src).getroot().tag, 'tag')