diff options
| author | Wu Haotian <whtsky@gmail.com> | 2021-07-05 14:17:31 +0800 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-07-05 09:01:54 +0200 |
| commit | b3b04ad2111f1e3eb0640cd5d51d4391655317ce (patch) | |
| tree | 6592bcbbf5897d16e2e3c843fcc73452193b0f1c | |
| parent | e4da3654367cd5f5c06ab109ece0042631faaa02 (diff) | |
Refs #28574 -- Added test for XML format output to Queryset.explain().
| -rw-r--r-- | tests/queries/test_explain.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/queries/test_explain.py b/tests/queries/test_explain.py index 4a22656657..9bf7de687a 100644 --- a/tests/queries/test_explain.py +++ b/tests/queries/test_explain.py @@ -1,4 +1,5 @@ import unittest +import xml.etree.ElementTree from django.db import NotSupportedError, connection, transaction from django.db.models import Count @@ -31,6 +32,13 @@ class ExplainTests(TestCase): self.assertTrue(captured_queries[0]['sql'].startswith(connection.ops.explain_prefix)) self.assertIsInstance(result, str) self.assertTrue(result) + if format == 'xml': + try: + xml.etree.ElementTree.fromstring(result) + except xml.etree.ElementTree.ParseError as e: + self.fail( + f'QuerySet.explain() result is not valid XML: {e}' + ) @skipUnlessDBFeature('validates_explain_options') def test_unknown_options(self): |
