def test_completion(self): # Load plugin commands config['pluginpath'] = [_common.PLUGINPATH] config['plugins'] = ['test'] # Do not load any other bash completion scripts on the system. env = dict(os.environ) env['BASH_COMPLETION_DIR'] = os.devnull env['BASH_COMPLETION_COMPAT_DIR'] = os.devnull # Open a `bash` process to run the tests in. We'll pipe in bash # commands via stdin. cmd = os.environ.get('BEETS_TEST_SHELL', '/bin/bash --norc').split() if not has_program(cmd[0]): self.skipTest(u'bash not available') tester = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, env=env) # Load bash_completion library. for path in commands.BASH_COMPLETION_PATHS: if os.path.exists(util.syspath(path)): bash_completion = path break else: self.skipTest(u'bash-completion script not found') try: with open(util.syspath(bash_completion), 'rb') as f: tester.stdin.writelines(f) except IOError: self.skipTest(u'could not read bash-completion script') # Load completion script. self.io.install() self.run_command('completion', lib=None) completion_script = self.io.getoutput().encode('utf-8') self.io.restore() tester.stdin.writelines(completion_script.splitlines(True)) # Load test suite. test_script_name = os.path.join(_common.RSRC, b'test_completion.sh') with open(test_script_name, 'rb') as test_script_file: tester.stdin.writelines(test_script_file) out, err = tester.communicate() if tester.returncode != 0 or out != b'completion tests passed\n': print(out.decode('utf-8')) self.fail(u'test/test_completion.sh did not execute properly')
def test_completion(self): # Load plugin commands config['pluginpath'] = [os.path.join(_common.RSRC, 'beetsplug')] config['plugins'] = ['test'] # Tests run in bash cmd = os.environ.get('BEETS_TEST_SHELL', '/bin/bash --norc').split() if not has_program(cmd[0]): self.skipTest(u'bash not available') tester = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE) # Load bash_completion library. for path in commands.BASH_COMPLETION_PATHS: if os.path.exists(util.syspath(path)): bash_completion = path break else: self.skipTest(u'bash-completion script not found') try: with open(util.syspath(bash_completion), 'r') as f: tester.stdin.writelines(f) except IOError: self.skipTest(u'could not read bash-completion script') # Load completion script. self.io.install() ui._raw_main(['completion']) completion_script = self.io.getoutput() self.io.restore() tester.stdin.writelines(completion_script) # Load test suite. test_script = os.path.join(_common.RSRC, 'test_completion.sh') with open(test_script, 'r') as test_script: tester.stdin.writelines(test_script) (out, err) = tester.communicate() if tester.returncode != 0 or out != u"completion tests passed\n": print(out) self.fail(u'test/test_completion.sh did not execute properly')
def test_completion(self): # Load plugin commands config['pluginpath'] = [_common.PLUGINPATH] config['plugins'] = ['test'] # Tests run in bash cmd = os.environ.get('BEETS_TEST_SHELL', '/bin/bash --norc').split() if not has_program(cmd[0]): self.skipTest(u'bash not available') tester = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE) # Load bash_completion library. for path in commands.BASH_COMPLETION_PATHS: if os.path.exists(util.syspath(path)): bash_completion = path break else: self.skipTest(u'bash-completion script not found') try: with open(util.syspath(bash_completion), 'r') as f: tester.stdin.writelines(f) except IOError: self.skipTest(u'could not read bash-completion script') # Load completion script. self.io.install() ui._raw_main(['completion']) completion_script = self.io.getoutput() self.io.restore() tester.stdin.writelines(completion_script) # Load test suite. test_script = os.path.join(_common.RSRC, b'test_completion.sh') with open(test_script, 'r') as test_script: tester.stdin.writelines(test_script) (out, err) = tester.communicate() if tester.returncode != 0 or out != u"completion tests passed\n": print(out) self.fail(u'test/test_completion.sh did not execute properly')
def test_completion(self): # Load plugin commands config['pluginpath'] = [os.path.join(_common.RSRC, 'beetsplug')] config['plugins'] = ['test'] test_script = os.path.join( os.path.dirname(__file__), 'test_completion.sh' ) bash_completion = os.path.abspath(os.environ.get( 'BASH_COMPLETION_SCRIPT', '/etc/bash_completion')) # Tests run in bash cmd = os.environ.get('BEETS_TEST_SHELL', '/bin/bash --norc').split() if not has_program(cmd[0]): self.skipTest('bash not available') tester = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE) # Load bash_completion try: with open(bash_completion, 'r') as bash_completion: tester.stdin.writelines(bash_completion) except IOError: self.skipTest('bash-completion script not found') # Load complection script self.io.install() ui._raw_main(['completion']) completion_script = self.io.getoutput() self.io.restore() tester.stdin.writelines(completion_script) # Load testsuite with open(test_script, 'r') as test_script: tester.stdin.writelines(test_script) (out, err) = tester.communicate() if tester.returncode != 0 or out != "completion tests passed\n": print(out) self.fail('test/test_completion.sh did not execute properly')
def test_completion(self): # Load plugin commands config["pluginpath"] = [os.path.join(_common.RSRC, "beetsplug")] config["plugins"] = ["test"] # Tests run in bash cmd = os.environ.get("BEETS_TEST_SHELL", "/bin/bash --norc").split() if not has_program(cmd[0]): self.skipTest("bash not available") tester = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE) # Load bash_completion library. for path in commands.BASH_COMPLETION_PATHS: if os.path.exists(util.syspath(path)): bash_completion = path break else: self.skipTest("bash-completion script not found") try: with open(util.syspath(bash_completion), "r") as f: tester.stdin.writelines(f) except IOError: self.skipTest("could not read bash-completion script") # Load completion script. self.io.install() ui._raw_main(["completion"]) completion_script = self.io.getoutput() self.io.restore() tester.stdin.writelines(completion_script) # Load test suite. test_script = os.path.join(_common.RSRC, "test_completion.sh") with open(test_script, "r") as test_script: tester.stdin.writelines(test_script) (out, err) = tester.communicate() if tester.returncode != 0 or out != "completion tests passed\n": print(out) self.fail("test/test_completion.sh did not execute properly")
from test.helper import TestHelper, has_program from beets import config from beets.mediafile import MediaFile from beetsplug.replaygain import (FatalGstreamerPluginReplayGainError, GStreamerBackend) try: import gi gi.require_version('Gst', '1.0') GST_AVAILABLE = True except (ImportError, ValueError): GST_AVAILABLE = False if any(has_program(cmd, ['-v']) for cmd in ['mp3gain', 'aacgain']): GAIN_PROG_AVAILABLE = True else: GAIN_PROG_AVAILABLE = False if has_program('bs1770gain', ['--replaygain']): LOUDNESS_PROG_AVAILABLE = True else: LOUDNESS_PROG_AVAILABLE = False class ReplayGainCliTestBase(TestHelper): def setUp(self): self.setup_beets() self.config['replaygain']['backend'] = self.backend
from __future__ import (division, absolute_import, print_function, unicode_literals) from test._common import unittest from test.helper import TestHelper, has_program from beets.mediafile import MediaFile try: import gi gi.require_version('Gst', '1.0') GST_AVAILABLE = True except ImportError, ValueError: GST_AVAILABLE = False if any(has_program(cmd, ['-v']) for cmd in ['mp3gain', 'aacgain']): GAIN_PROG_AVAILABLE = True else: GAIN_PROG_AVAILABLE = False class ReplayGainCliTestBase(TestHelper): def setUp(self): self.setup_beets() try: self.load_plugins('replaygain') except: self.teardown_beets() self.unload_plugins() raise
import unittest from mediafile import MediaFile from beets import config from beetsplug.replaygain import (FatalGstreamerPluginReplayGainError, GStreamerBackend) from test.helper import TestHelper, has_program try: import gi gi.require_version('Gst', '1.0') GST_AVAILABLE = True except (ImportError, ValueError): GST_AVAILABLE = False if any(has_program(cmd, ['-v']) for cmd in ['mp3gain', 'aacgain']): GAIN_PROG_AVAILABLE = True else: GAIN_PROG_AVAILABLE = False FFMPEG_AVAILABLE = has_program('ffmpeg', ['-version']) def reset_replaygain(item): item['rg_track_peak'] = None item['rg_track_gain'] = None item['rg_album_gain'] = None item['rg_album_gain'] = None item['r128_track_gain'] = None item['r128_album_gain'] = None item.write()
from __future__ import division, absolute_import, print_function, unicode_literals from test._common import unittest from test.helper import TestHelper, has_program from beets.mediafile import MediaFile try: import gi gi.require_version("Gst", "1.0") GST_AVAILABLE = True except (ImportError, ValueError): GST_AVAILABLE = False if any(has_program(cmd, ["-v"]) for cmd in ["mp3gain", "aacgain"]): GAIN_PROG_AVAILABLE = True else: GAIN_PROG_AVAILABLE = False if has_program("bs1770gain", ["--replaygain"]): LOUDNESS_PROG_AVAILABLE = True else: LOUDNESS_PROG_AVAILABLE = False class ReplayGainCliTestBase(TestHelper): def setUp(self): self.setup_beets() try: