From 22c524f0d692e69d865dc42aeb9150f67e77b77d Mon Sep 17 00:00:00 2001 From: Kudlaty Date: Tue, 16 Apr 2013 18:26:04 +0200 Subject: [PATCH] Fix E901 SyntaxError in python3.2 --- compressor/tests/test_offline.py | 2 +- compressor/utils/stringformat.py | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/compressor/tests/test_offline.py b/compressor/tests/test_offline.py index fc94938..2ad764d 100644 --- a/compressor/tests/test_offline.py +++ b/compressor/tests/test_offline.py @@ -259,7 +259,7 @@ class OfflineGenerationInlineNonAsciiTestCase(OfflineTestCaseMixin, TestCase): def setUp(self): self.old_offline_context = settings.COMPRESS_OFFLINE_CONTEXT settings.COMPRESS_OFFLINE_CONTEXT = { - 'test_non_ascii_value': u'\u2014', + 'test_non_ascii_value': '\u2014', } super(OfflineGenerationInlineNonAsciiTestCase, self).setUp() diff --git a/compressor/utils/stringformat.py b/compressor/utils/stringformat.py index 0fd3f6d..9311e78 100644 --- a/compressor/utils/stringformat.py +++ b/compressor/utils/stringformat.py @@ -6,6 +6,8 @@ An implementation of the advanced string formatting (PEP 3101). Author: Florent Xicluna """ +from __future__ import unicode_literals + import re from django.utils import six @@ -140,9 +142,9 @@ class FormattableString(object): The method format() behaves like str.format() in python 2.6+. - >>> FormattableString(u'{a:5}').format(a=42) - ... # Same as u'{a:5}'.format(a=42) - u' 42' + >>> FormattableString('{a:5}').format(a=42) + ... # Same as '{a:5}'.format(a=42) + ' 42' """ @@ -246,12 +248,12 @@ def selftest(): import datetime F = FormattableString - assert F(u"{0:{width}.{precision}s}").format('hello world', - width=8, precision=5) == u'hello ' + assert F("{0:{width}.{precision}s}").format('hello world', + width=8, precision=5) == 'hello ' d = datetime.date(2010, 9, 7) - assert F(u"The year is {0.year}").format(d) == u"The year is 2010" - assert F(u"Tested on {0:%Y-%m-%d}").format(d) == u"Tested on 2010-09-07" + assert F("The year is {0.year}").format(d) == "The year is 2010" + assert F("Tested on {0:%Y-%m-%d}").format(d) == "Tested on 2010-09-07" print('Test successful') if __name__ == '__main__':