From 8043ff3fefd1b59bb1d3c93595fdc10b7ae04abc Mon Sep 17 00:00:00 2001 From: Artem Muterko Date: Fri, 20 Jan 2017 22:09:47 +0200 Subject: [PATCH] Add test for urlquote_wrapper (#4832) --- tests/test_templatetags.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test_templatetags.py b/tests/test_templatetags.py index 7cf3690a4..87d5cbc81 100644 --- a/tests/test_templatetags.py +++ b/tests/test_templatetags.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals from django.test import TestCase from rest_framework.relations import Hyperlink +from rest_framework.templatetags import rest_framework from rest_framework.templatetags.rest_framework import ( add_nested_class, add_query_param, as_string, break_long_headers, format_value, get_pagination_html, urlize_quoted_links @@ -268,6 +269,15 @@ class Issue1386Tests(TestCase): # example from issue #1386, this shouldn't raise an exception urlize_quoted_links("asdf:[/p]zxcv.com") + def test_smart_urlquote_wrapper_handles_value_error(self): + def mock_smart_urlquote(url): + raise ValueError + + old = rest_framework.smart_urlquote + rest_framework.smart_urlquote = mock_smart_urlquote + assert rest_framework.smart_urlquote_wrapper('test') is None + rest_framework.smart_urlquote = old + class URLizerTests(TestCase): """