mirror of
https://github.com/beetbox/beets.git
synced 2025-12-15 21:14:19 +01:00
Portable mock command for testing convert plugin
This commit is contained in:
parent
2b9f4773a9
commit
33a4767eaf
2 changed files with 10 additions and 7 deletions
|
|
@ -199,9 +199,10 @@ class ConvertPlugin(BeetsPlugin):
|
|||
# Something went wrong (probably Ctrl+C), remove temporary files
|
||||
self._log.info(u'Encoding {0} failed. Cleaning up...',
|
||||
util.displayable_path(source))
|
||||
self._log.debug(u'Command {0} exited with status {1}',
|
||||
exc.cmd.decode('utf8', 'ignore'),
|
||||
exc.returncode)
|
||||
self._log.debug(u'Command {0} exited with status {1}: {2}',
|
||||
args,
|
||||
exc.returncode,
|
||||
exc.output)
|
||||
util.remove(dest)
|
||||
util.prune_dirs(os.path.dirname(dest))
|
||||
raise
|
||||
|
|
|
|||
|
|
@ -35,10 +35,12 @@ class TestHelper(helper.TestHelper):
|
|||
if re.search('[^a-zA-Z0-9]', tag):
|
||||
raise ValueError(u"tag '{0}' must only contain letters and digits"
|
||||
.format(tag))
|
||||
# FIXME This is not portable. For windows we need to use our own
|
||||
# python script that performs the same task.
|
||||
return u'sh -c "cp \'$source\' \'$dest\'; ' \
|
||||
u'printf {0} >> \'$dest\'"'.format(tag)
|
||||
|
||||
# A Python script that copies the file and appends a tag.
|
||||
return u'python -c \'import sys; inf = open(sys.argv[1], "rb"); ' \
|
||||
u'outf = open(sys.argv[2], "wb"); ' \
|
||||
u'outf.write(inf.read()); ' \
|
||||
u'outf.write(b"{}")\' $source $dest'.format(tag)
|
||||
|
||||
def assertFileTag(self, path, tag): # noqa
|
||||
"""Assert that the path is a file and the files content ends with `tag`.
|
||||
|
|
|
|||
Loading…
Reference in a new issue