mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 08:39:17 +01:00
test_play: Remove files generated by play plugin
This commit is contained in:
parent
c9045215c1
commit
0682d0d030
2 changed files with 13 additions and 10 deletions
|
|
@ -18,12 +18,12 @@
|
|||
import shlex
|
||||
import subprocess
|
||||
from os.path import relpath
|
||||
from tempfile import NamedTemporaryFile
|
||||
|
||||
from beets import config, ui, util
|
||||
from beets.plugins import BeetsPlugin
|
||||
from beets.ui import Subcommand
|
||||
from beets.ui.commands import PromptChoice
|
||||
from beets.util import get_temp_filename
|
||||
|
||||
# Indicate where arguments should be inserted into the command string.
|
||||
# If this is missing, they're placed at the end.
|
||||
|
|
@ -194,15 +194,15 @@ class PlayPlugin(BeetsPlugin):
|
|||
def _create_tmp_playlist(self, paths_list):
|
||||
"""Create a temporary .m3u file. Return the filename."""
|
||||
utf8_bom = config["play"]["bom"].get(bool)
|
||||
m3u = NamedTemporaryFile("wb", suffix=".m3u", delete=False)
|
||||
filename = get_temp_filename(__name__, suffix=".m3u")
|
||||
with open(filename, "wb") as m3u:
|
||||
if utf8_bom:
|
||||
m3u.write(b"\xEF\xBB\xBF")
|
||||
|
||||
if utf8_bom:
|
||||
m3u.write(b"\xEF\xBB\xBF")
|
||||
for item in paths_list:
|
||||
m3u.write(item + b"\n")
|
||||
|
||||
for item in paths_list:
|
||||
m3u.write(item + b"\n")
|
||||
m3u.close()
|
||||
return m3u.name
|
||||
return filename
|
||||
|
||||
def before_choose_candidate_listener(self, session, task):
|
||||
"""Append a "Play" choice to the interactive importer prompt."""
|
||||
|
|
|
|||
|
|
@ -20,13 +20,16 @@ import sys
|
|||
import unittest
|
||||
from unittest.mock import ANY, patch
|
||||
|
||||
from beets.test.helper import TestHelper, control_stdin
|
||||
from beets.test.helper import CleanupModulesMixin, TestHelper, control_stdin
|
||||
from beets.ui import UserError
|
||||
from beets.util import open_anything
|
||||
from beetsplug.play import PlayPlugin
|
||||
|
||||
|
||||
@patch("beetsplug.play.util.interactive_open")
|
||||
class PlayPluginTest(unittest.TestCase, TestHelper):
|
||||
class PlayPluginTest(CleanupModulesMixin, unittest.TestCase, TestHelper):
|
||||
modules = (PlayPlugin.__module__,)
|
||||
|
||||
def setUp(self):
|
||||
self.setup_beets()
|
||||
self.load_plugins("play")
|
||||
|
|
|
|||
Loading…
Reference in a new issue