Commit 74884f33 by Frankie Dintino

Fix to shlex.split for *_(BINARY|ARGUMENTS) settings on windows

shlex.split(), without posix=False, strips "\" characters, which is
obviously problematic on windows.
parent 0ed51f71
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import os
import collections
import shlex
......@@ -101,7 +102,7 @@ class PipelineSettings(collections.MutableMapping):
value = self.settings[key]
if key.endswith(("_BINARY", "_ARGUMENTS")):
if isinstance(value, string_types):
return tuple(shlex.split(value))
return tuple(shlex.split(value, posix=(os.name == 'posix')))
return tuple(value)
return value
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import sys
from unittest import skipIf, skipUnless
from django.test import TestCase
from pipeline.conf import PipelineSettings
......@@ -23,10 +26,16 @@ class TestSettings(TestCase):
s = PipelineSettings({"FOO_BINARY": "env actualprogram"})
self.assertEqual(s.FOO_BINARY, ('env', 'actualprogram'))
@skipIf(sys.platform.startswith("win"), "requires posix platform")
def test_expected_preservation(self):
s = PipelineSettings({"FOO_BINARY": r"actual\ program"})
self.assertEqual(s.FOO_BINARY, ('actual program',))
@skipUnless(sys.platform.startswith("win"), "requires windows")
def test_win_path_preservation(self):
s = PipelineSettings({"FOO_BINARY": "C:\\Test\\ActualProgram.exe argument"})
self.assertEqual(s.FOO_BINARY, ('C:\\Test\\ActualProgram.exe', 'argument'))
def test_tuples_are_normal(self):
s = PipelineSettings({"FOO_ARGUMENTS": ("explicit", "with", "args")})
self.assertEqual(s.FOO_ARGUMENTS, ('explicit', 'with', 'args'))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment