Update platform command and test for Python 2 & 3
Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
This commit is contained in:
@@ -40,8 +40,11 @@ class Command(management.BaseCommand):
|
||||
)
|
||||
exit(1)
|
||||
else:
|
||||
# Python 2 & 3 way to convert from SafeString to unicode
|
||||
self.stdout.write(
|
||||
'{}'.format(
|
||||
template().render(
|
||||
context_string=options.get('context')
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user