From 67fa2792d9b285dd07ffd804554edc966c7ff83f Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Sun, 12 Jan 2020 14:23:10 +0100 Subject: [PATCH] extend the helper functions with the escape function When the object_to_find string contained a special character which the django template system escapes then the test filed because the helpers where looking for the unescaped string. Now they escape the string as well. --- core/tests/helper.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/tests/helper.py b/core/tests/helper.py index d27e108..27a1065 100644 --- a/core/tests/helper.py +++ b/core/tests/helper.py @@ -1,12 +1,15 @@ +from django.utils.html import escape + + def in_content(response, object_to_find): decoded_content = response.content.decode('utf8') - if str(object_to_find) not in decoded_content: + if str(escape(object_to_find)) not in decoded_content: return False return True def not_in_content(response, object_to_find): decoded_content = response.content.decode('utf8') - if str(object_to_find) in decoded_content: + if str(escape(object_to_find)) in decoded_content: return False return True