Update platform command and test for Python 2 & 3

Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
This commit is contained in:
Roberto Rosario
2019-10-28 03:32:36 -04:00
parent 61f398a3b9
commit 6b4392a35c
2 changed files with 8 additions and 5 deletions

View File

@@ -40,8 +40,11 @@ class Command(management.BaseCommand):
)
exit(1)
else:
# Python 2 & 3 way to convert from SafeString to unicode
self.stdout.write(
template().render(
context_string=options.get('context')
'{}'.format(
template().render(
context_string=options.get('context')
)
)
)

View File

@@ -1,6 +1,6 @@
from __future__ import unicode_literals
from io import BytesIO
from django.utils.six import StringIO
from django.core import management
from django.test import TestCase
@@ -38,7 +38,7 @@ PlatformTemplate.register(klass=TestPlatformTemplate)
class PlatformTemplateManagementCommandTestCase(TestCase):
def test_platform_template_simple(self):
output = BytesIO()
output = StringIO()
args = (TEST_TEMPLATE_NAME,)
options = {
'stdout': output
@@ -47,7 +47,7 @@ class PlatformTemplateManagementCommandTestCase(TestCase):
self.assertEqual(output.getvalue(), TEST_TEMPLATE_STRING_RENDER)
def test_platform_template_context(self):
output = BytesIO()
output = StringIO()
args = (
TEST_TEMPLATE_NAME, '--context',
'test_template_variable: {}'.format(