Merge pull request #2403 from antlarr/master

Run python2 or python3 depending on what's being used
This commit is contained in:
Adrian Sampson 2017-04-15 11:28:45 -04:00
commit 0cbb40869a

View file

@ -15,6 +15,7 @@
from __future__ import division, absolute_import, print_function
import sys
import re
import os.path
import unittest
@ -27,6 +28,15 @@ from beets.mediafile import MediaFile
from beets import util
def shell_quote(text):
if sys.version_info[0] < 3:
import pipes
return pipes.quote(text)
else:
import shlex
return shlex.quote(text)
class TestHelper(helper.TestHelper):
def tagged_copy_cmd(self, tag):
@ -39,7 +49,8 @@ class TestHelper(helper.TestHelper):
# A Python script that copies the file and appends a tag.
stub = os.path.join(_common.RSRC, b'convert_stub.py').decode('utf-8')
return u"python '{}' $source $dest {}".format(stub, tag)
return u"{} {} $source $dest {}".format(shell_quote(sys.executable),
shell_quote(stub), tag)
def assertFileTag(self, path, tag): # noqa
"""Assert that the path is a file and the files content ends with `tag`.
@ -273,5 +284,6 @@ class NeverConvertLossyFilesTest(unittest.TestCase, TestHelper,
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == '__main__':
unittest.main(defaultTest='suite')