diff --git a/test/_common.py b/test/_common.py index 21c73858e..8105ef342 100644 --- a/test/_common.py +++ b/test/_common.py @@ -346,3 +346,11 @@ def system_mock(name): yield finally: platform.system = old_system + + +def slowTest(unused=None): + def _id(obj): + return obj + if 'SKIP_SLOW_TESTS' in os.environ: + return unittest.skip('test is slow') + return _id diff --git a/test/test_art.py b/test/test_art.py index d4ca814a5..b7b52c245 100644 --- a/test/test_art.py +++ b/test/test_art.py @@ -261,8 +261,7 @@ class GoogleImageTest(UseThePlugin): self.assertEqual(list(result_url), []) -@unittest.skipIf('SKIP_SLOW_TESTS' in os.environ, - 'Skipping because test is slow') +@_common.slowTest() class ArtImporterTest(UseThePlugin): def setUp(self): super(ArtImporterTest, self).setUp() diff --git a/test/test_convert.py b/test/test_convert.py index e6f75c0ad..8ba71bdc9 100644 --- a/test/test_convert.py +++ b/test/test_convert.py @@ -64,8 +64,7 @@ class TestHelper(helper.TestHelper): .format(path, tag)) -@unittest.skipIf('SKIP_SLOW_TESTS' in os.environ, - 'Skipping because test is slow') +@_common.slowTest() class ImportConvertTest(unittest.TestCase, TestHelper): def setUp(self): @@ -101,8 +100,7 @@ class ImportConvertTest(unittest.TestCase, TestHelper): self.assertTrue(os.path.isfile(item.path)) -@unittest.skipIf('SKIP_SLOW_TESTS' in os.environ, - 'Skipping because test is slow') +@_common.slowTest() class ConvertCliTest(unittest.TestCase, TestHelper): def setUp(self): @@ -190,8 +188,7 @@ class ConvertCliTest(unittest.TestCase, TestHelper): self.assertFalse(os.path.exists(converted)) -@unittest.skipIf('SKIP_SLOW_TESTS' in os.environ, - 'Skipping because test is slow') +@_common.slowTest() class NeverConvertLossyFilesTest(unittest.TestCase, TestHelper): """Test the effect of the `never_convert_lossy_files` option. """ diff --git a/test/test_dbcore.py b/test/test_dbcore.py index 00ef2f1fb..4b4cc18bb 100644 --- a/test/test_dbcore.py +++ b/test/test_dbcore.py @@ -22,6 +22,7 @@ import os import shutil import sqlite3 +from test import _common from test._common import unittest from beets import dbcore from tempfile import mkstemp @@ -127,8 +128,7 @@ class TestModelWithGetters(dbcore.Model): return {} -@unittest.skipIf('SKIP_SLOW_TESTS' in os.environ, - 'Skipping because test is slow') +@_common.slowTest() class MigrationTest(unittest.TestCase): """Tests the ability to change the database schema between versions. diff --git a/test/test_edit.py b/test/test_edit.py index 34bad25a7..106cf1f25 100644 --- a/test/test_edit.py +++ b/test/test_edit.py @@ -15,9 +15,9 @@ from __future__ import (division, absolute_import, print_function, unicode_literals) import codecs -import os from mock import patch +from test import _common from test._common import unittest from test.helper import TestHelper, control_stdin @@ -63,8 +63,7 @@ class ModifyFileMocker(object): f.write(contents) -@unittest.skipIf('SKIP_SLOW_TESTS' in os.environ, - 'Skipping because test is slow') +@_common.slowTest() class EditCommandTest(unittest.TestCase, TestHelper): """ Black box tests for `beetsplug.edit`. Command line interaction is simulated using `test.helper.control_stdin()`, and yaml editing via an diff --git a/test/test_importer.py b/test/test_importer.py index 27dcd5a12..fea4d78a0 100644 --- a/test/test_importer.py +++ b/test/test_importer.py @@ -236,8 +236,7 @@ class ImportHelper(TestHelper): self.assertEqual(len(os.listdir(self.libdir)), 0) -@unittest.skipIf('SKIP_SLOW_TESTS' in os.environ, - 'Skipping because test is slow') +@_common.slowTest() class NonAutotaggedImportTest(_common.TestCase, ImportHelper): def setUp(self): self.setup_beets(disk=True) diff --git a/test/test_logging.py b/test/test_logging.py index 8517f0a3f..478b7a7c6 100644 --- a/test/test_logging.py +++ b/test/test_logging.py @@ -5,7 +5,6 @@ from __future__ import (division, absolute_import, print_function, unicode_literals) import sys -import os import threading import logging as log from StringIO import StringIO @@ -13,6 +12,7 @@ from StringIO import StringIO import beets.logging as blog from beets import plugins, ui import beetsplug +from test import _common from test._common import unittest, TestCase from test import helper @@ -164,8 +164,7 @@ class LoggingLevelTest(unittest.TestCase, helper.TestHelper): self.assertIn('dummy: debug import_stage', logs) -@unittest.skipIf('SKIP_SLOW_TESTS' in os.environ, - 'Skipping because test is slow') +@_common.slowTest() class ConcurrentEventsTest(TestCase, helper.TestHelper): """Similar to LoggingLevelTest but lower-level and focused on multiple events interaction. Since this is a bit heavy we don't do it in diff --git a/test/test_ui.py b/test/test_ui.py index 08097b3f2..207d39261 100644 --- a/test/test_ui.py +++ b/test/test_ui.py @@ -594,8 +594,7 @@ class InputTest(_common.TestCase): self.assertEqual(album, u'\xc2me') -@unittest.skipIf('SKIP_SLOW_TESTS' in os.environ, - 'Skipping because test is slow') +@_common.slowTest() class ConfigTest(unittest.TestCase, TestHelper): def setUp(self): self.setup_beets() @@ -1037,8 +1036,7 @@ class PathFormatTest(_common.TestCase): self.assertEqual(pf[1:], default_formats) -@unittest.skipIf('SKIP_SLOW_TESTS' in os.environ, - 'Skipping because test is slow') +@_common.slowTest() class PluginTest(_common.TestCase): def test_plugin_command_from_pluginpath(self): config['pluginpath'] = [os.path.join(_common.RSRC, 'beetsplug')] @@ -1046,8 +1044,7 @@ class PluginTest(_common.TestCase): ui._raw_main(['test']) -@unittest.skipIf('SKIP_SLOW_TESTS' in os.environ, - 'Skipping because test is slow') +@_common.slowTest() class CompletionTest(_common.TestCase): def test_completion(self): # Load plugin commands