diff --git a/rest_framework_xml/parsers.py b/rest_framework_xml/parsers.py index b6364c4..7e1bd4a 100644 --- a/rest_framework_xml/parsers.py +++ b/rest_framework_xml/parsers.py @@ -39,7 +39,7 @@ def parse(self, stream, media_type=None, parser_context=None): def _check_xml_list(self, element): """ - Checks that an element has multiple tags and that they are all the same, + Checks that an element has multiple tags and that they are all the same, to validate that the element is a properly formatted list """ return len(element) > 1 and len(set([child.tag for child in element])) <= 1 diff --git a/tests/test_parsers.py b/tests/test_parsers.py index 27258a8..3e5597a 100644 --- a/tests/test_parsers.py +++ b/tests/test_parsers.py @@ -4,6 +4,7 @@ from django.test import TestCase +from django.utils import unittest from django.utils.six.moves import StringIO from rest_framework_xml.parsers import XMLParser from rest_framework_xml.compat import etree @@ -95,21 +96,25 @@ def setUp(self): ] } + @unittest.skipUnless(etree, 'defusedxml not installed') def test_parse(self): parser = XMLParser() data = parser.parse(self._input) self.assertEqual(data, self._data) + @unittest.skipUnless(etree, 'defusedxml not installed') def test_complex_data_parse(self): parser = XMLParser() data = parser.parse(self._complex_data_input) self.assertEqual(data, self._complex_data) + @unittest.skipUnless(etree, 'defusedxml not installed') def test_invalid_list_parse(self): parser = XMLParser() data = parser.parse(self._invalid_list_input) self.assertEqual(data, self._invalid_list_output) + @unittest.skipUnless(etree, 'defusedxml not installed') def test_valid_list_parse(self): parser = XMLParser() data = parser.parse(self._valid_list_input) diff --git a/tests/test_renderers.py b/tests/test_renderers.py index 76be755..99c5f22 100644 --- a/tests/test_renderers.py +++ b/tests/test_renderers.py @@ -5,6 +5,7 @@ from decimal import Decimal from django.test import TestCase +from django.utils import unittest from django.utils.six.moves import StringIO from rest_framework_xml.renderers import XMLRenderer from rest_framework_xml.parsers import XMLParser @@ -96,6 +97,7 @@ def test_render_list(self): self.assertXMLContains(content, '') self.assertXMLContains(content, '') + @unittest.skipUnless(etree, 'defusedxml not installed') def test_render_and_parse_complex_data(self): """ Test XML rendering.