Fixed tests for Py3

This commit is contained in:
Martin Mahner 2017-09-13 09:26:14 +02:00
parent f936bd43c3
commit cf61cc52d4
3 changed files with 4 additions and 2 deletions

View file

@ -145,4 +145,5 @@ def pygmentize(code_string, lexer_name=LEXER_DEFAULT):
or PythonLexer() or PythonLexer()
except Exception: except Exception:
lexer = PythonLexer() lexer = PythonLexer()
return highlight(code_string, lexer, NakedHtmlFormatter()) return highlight(code_string, lexer, NakedHtmlFormatter())

View file

@ -76,7 +76,7 @@ class SnippetTestCase(TestCase):
# The unicode method contains the snippet id so we can easily print # The unicode method contains the snippet id so we can easily print
# the id using {{ snippet }} # the id using {{ snippet }}
snippet = Snippet.objects.all()[0] snippet = Snippet.objects.all()[0]
self.assertTrue(snippet.secret_id in snippet.__unicode__()) self.assertTrue(snippet.secret_id in snippet.__str__())
def test_new_snippet_custom_lexer(self): def test_new_snippet_custom_lexer(self):
# You can pass a lexer key in GET.l # You can pass a lexer key in GET.l

View file

@ -12,6 +12,7 @@ from django.http import (Http404, HttpResponse, HttpResponseBadRequest,
HttpResponseRedirect) HttpResponseRedirect)
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from django.utils.decorators import method_decorator from django.utils.decorators import method_decorator
from django.utils.encoding import force_text
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.views.decorators.csrf import csrf_exempt from django.views.decorators.csrf import csrf_exempt
from django.views.defaults import page_not_found as django_page_not_found, \ from django.views.defaults import page_not_found as django_page_not_found, \
@ -210,7 +211,7 @@ class SnippetDiffView(TemplateView):
diff.content = '\n'.join(d).strip() diff.content = '\n'.join(d).strip()
diff.lexer = 'diff' diff.lexer = 'diff'
else: else:
diff.content = _(u'No changes were made between this two files.') diff.content = force_text(_(u'No changes were made between this two files.'))
diff.lexer = 'text' diff.lexer = 'text'
return diff return diff