11from unittest .mock import Mock , patch
22from urllib .parse import urlencode
3+ from xml .etree import ElementTree
34
45from django .template .loader import render_to_string
56from django .test import TestCase
@@ -17,7 +18,10 @@ def test_call_app(self):
1718 self .maxDiff = None
1819 url = reverse ('two_factor_twilio:call_app' , args = ['123456' ])
1920 response = self .client .get (url )
20- self .assertEqual (response .content .decode ('utf-8' ), """<?xml version="1.0" encoding="UTF-8" ?>
21+ content = response .content .decode ('utf-8' )
22+ # raises an exception if invalid xml
23+ ElementTree .fromstring (content )
24+ self .assertEqual (content , """<?xml version="1.0" encoding="UTF-8" ?>
2125<Response>
2226 <Gather timeout="15" numDigits="1" finishOnKey="">
2327 <Say language="en">Hi, this is testserver calling. Press any key to continue.</Say>
@@ -27,7 +31,10 @@ def test_call_app(self):
2731
2832 url = reverse ('two_factor_twilio:call_app' , args = ['123456' ])
2933 response = self .client .post (url )
30- self .assertEqual (response .content .decode ('utf-8' ), """<?xml version="1.0" encoding="UTF-8" ?>
34+ content = response .content .decode ('utf-8' )
35+ # raises an exception if invalid xml
36+ ElementTree .fromstring (content )
37+ self .assertEqual (content , """<?xml version="1.0" encoding="UTF-8" ?>
3138<Response>
3239 <Say language="en">Your token is:</Say>
3340 <Pause/>
0 commit comments