From cf61cc52d443f81a22caf7dcee22429121324482 Mon Sep 17 00:00:00 2001 From: Martin Mahner Date: Wed, 13 Sep 2017 09:26:14 +0200 Subject: [PATCH] Fixed tests for Py3 --- dpaste/highlight.py | 1 + dpaste/tests/test_snippet.py | 2 +- dpaste/views.py | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dpaste/highlight.py b/dpaste/highlight.py index 1b7f44f..c5aae06 100644 --- a/dpaste/highlight.py +++ b/dpaste/highlight.py @@ -145,4 +145,5 @@ def pygmentize(code_string, lexer_name=LEXER_DEFAULT): or PythonLexer() except Exception: lexer = PythonLexer() + return highlight(code_string, lexer, NakedHtmlFormatter()) diff --git a/dpaste/tests/test_snippet.py b/dpaste/tests/test_snippet.py index bbb3858..60c39e2 100644 --- a/dpaste/tests/test_snippet.py +++ b/dpaste/tests/test_snippet.py @@ -76,7 +76,7 @@ class SnippetTestCase(TestCase): # The unicode method contains the snippet id so we can easily print # the id using {{ snippet }} 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): # You can pass a lexer key in GET.l diff --git a/dpaste/views.py b/dpaste/views.py index d8abfcd..ac30c6e 100644 --- a/dpaste/views.py +++ b/dpaste/views.py @@ -12,6 +12,7 @@ from django.http import (Http404, HttpResponse, HttpResponseBadRequest, HttpResponseRedirect) from django.shortcuts import get_object_or_404 from django.utils.decorators import method_decorator +from django.utils.encoding import force_text from django.utils.translation import ugettext_lazy as _ from django.views.decorators.csrf import csrf_exempt 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.lexer = 'diff' 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' return diff