Skip to content

Commit

Permalink
Skip extra tests instead of early returns
Browse files Browse the repository at this point in the history
This way it is clear when and why the tests are skipped.
  • Loading branch information
naglis committed Nov 13, 2024
1 parent b997003 commit 4c0ed01
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 176 deletions.
3 changes: 0 additions & 3 deletions aeneas/tests/bench_test_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
from aeneas.tools.execute_task import ExecuteTaskCLI


# TODO actually parse this file to know what extras
# (festival, speect, etc.) are available to test
EXTRA_TESTS = os.path.exists(os.path.join(os.path.expanduser("~"), ".aeneas.conf"))
BENCH_DIR = os.path.join(os.path.expanduser("~"), ".aeneas", "benchmark_input")
BENCH_TESTS = os.path.exists(BENCH_DIR)

Expand Down
3 changes: 0 additions & 3 deletions aeneas/tests/bench_test_task_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
from aeneas.tools.execute_task import ExecuteTaskCLI


# TODO actually parse this file to know what extras
# (festival, speect, etc.) are available to test
EXTRA_TESTS = os.path.exists(os.path.join(os.path.expanduser("~"), ".aeneas.conf"))
BENCH_DIR = os.path.join(os.path.expanduser("~"), ".aeneas", "benchmark_input")
BENCH_TESTS = os.path.exists(BENCH_DIR)

Expand Down
5 changes: 5 additions & 0 deletions aeneas/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
(val := os.getenv("UNITTEST_RUN_SLOW_TESTS")) is None or val.strip() == "0",
"slow tests are disabled. Set `UNITTEST_RUN_SLOW_TESTS=1` in the environment to enable them.",
)
EXTRA_TEST_PATH = os.path.join(os.path.expanduser("~"), ".aeneas.conf")
extra_test = unittest.skipIf(
not os.path.isfile(EXTRA_TEST_PATH),
f"extra tests are disabled (path {EXTRA_TEST_PATH!r} does not exist).",
)


class ExecuteCLICase(unittest.TestCase):
Expand Down
59 changes: 4 additions & 55 deletions aeneas/tests/test_long_job_rconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,9 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import os
import tempfile

from aeneas.tests.common import ExecuteJobCLICase, slow_test


# TODO actually parse this file to know what extras
# (festival, speect, etc.) are available to test
EXTRA_TESTS = os.path.exists(os.path.join(os.path.expanduser("~"), ".aeneas.conf"))
from aeneas.tests.common import ExecuteJobCLICase, slow_test, extra_test


@slow_test
Expand Down Expand Up @@ -103,9 +97,8 @@ def test_exec_cew_subprocess_path(self):
0,
)

@extra_test
def test_exec_cfw(self):
if not EXTRA_TESTS:
return
self.execute(
[
("in", "../tools/res/job.zip"),
Expand Down Expand Up @@ -136,20 +129,6 @@ def test_exec_dtw_margin(self):
0,
)

def test_exec_ffmpeg_path(self):
if not EXTRA_TESTS:
return
home = os.path.expanduser("~")
path = os.path.join(home, ".aeneas/myffmpeg")
self.execute(
[
("in", "../tools/res/job.zip"),
("out", ""),
("", '-r="ffmpeg_path=%s"' % path),
],
0,
)

def test_exec_ffmpeg_sample_rate(self):
self.execute(
[
Expand All @@ -160,20 +139,6 @@ def test_exec_ffmpeg_sample_rate(self):
0,
)

def test_exec_ffprobe_path(self):
if not EXTRA_TESTS:
return
home = os.path.expanduser("~")
path = os.path.join(home, ".aeneas/myffprobe")
self.execute(
[
("in", "../tools/res/job.zip"),
("out", ""),
("", '-r="ffprobe_path=%s"' % path),
],
0,
)

def test_exec_mfcc_emphasis_factor(self):
self.execute(
[
Expand Down Expand Up @@ -319,16 +284,14 @@ def test_exec_tmp_path(self):
0,
)

@extra_test
def test_exec_tts(self):
if not EXTRA_TESTS:
return
self.execute(
[("in", "../tools/res/job.zip"), ("out", ""), ("", '-r="tts=festival"')], 0
)

@extra_test
def test_exec_tts_cache(self):
if not EXTRA_TESTS:
return
self.execute(
[
("in", "../tools/res/job.zip"),
Expand All @@ -338,20 +301,6 @@ def test_exec_tts_cache(self):
0,
)

def test_exec_tts_path(self):
if not EXTRA_TESTS:
return
home = os.path.expanduser("~")
path = os.path.join(home, ".aeneas/myespeak")
self.execute(
[
("in", "../tools/res/job.zip"),
("out", ""),
("", '-r="tts=espeak|tts_path=%s"' % path),
],
0,
)

def test_exec_voice_code(self):
self.execute(
[
Expand Down
20 changes: 5 additions & 15 deletions aeneas/tests/test_long_task_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import os

from aeneas.tests.common import ExecuteTaskCLICase, slow_test


# TODO actually parse this file to know what extras
# (festival, speect, etc.) are available to test
EXTRA_TESTS = os.path.exists(os.path.join(os.path.expanduser("~"), ".aeneas.conf"))
from aeneas.tests.common import ExecuteTaskCLICase, slow_test, extra_test


@slow_test
Expand All @@ -41,9 +35,8 @@ def test_example_beforenext(self):
def test_example_cewsubprocess(self):
self.execute([("", "--example-cewsubprocess")], 0)

@extra_test
def test_example_ctw_espeak(self):
if not EXTRA_TESTS:
return
self.execute([("", "--example-ctw-espeak")], 0)

# NOTE disabling this test since it requires a speect voice
Expand All @@ -58,9 +51,8 @@ def test_example_eaf(self):
def test_example_faster_rate(self):
self.execute([("", "--example-faster-rate")], 0)

@extra_test
def test_example_festival(self):
if not EXTRA_TESTS:
return
self.execute([("", "--example-festival")], 0)

def test_example_flatten_12(self):
Expand All @@ -84,9 +76,8 @@ def test_example_mplain_json(self):
def test_example_mplain_smil(self):
self.execute([("", "--example-mplain-smil")], 0)

@extra_test
def test_example_multilevel_tts(self):
if not EXTRA_TESTS:
return
self.execute([("", "--example-multilevel-tts")], 0)

def test_example_munparsed_json(self):
Expand Down Expand Up @@ -140,9 +131,8 @@ def test_example_tsv(self):
def test_example_words(self):
self.execute([("", "--example-words")], 0)

@extra_test
def test_example_words_festival_cache(self):
if not EXTRA_TESTS:
return
self.execute([("", "--example-words-festival-cache")], 0)

def test_example_words_multilevel(self):
Expand Down
6 changes: 0 additions & 6 deletions aeneas/tests/test_long_task_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,10 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import os

from aeneas.tests.common import ExecuteTaskCLICase, slow_test


# TODO actually parse this file to know what extras
# (festival, speect, etc.) are available to test
EXTRA_TESTS = os.path.exists(os.path.join(os.path.expanduser("~"), ".aeneas.conf"))


@slow_test
class TestExecuteTaskCLI(ExecuteTaskCLICase):
def test_exec_aud(self):
Expand Down
15 changes: 3 additions & 12 deletions aeneas/tests/test_long_task_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import os

from aeneas.tests.common import ExecuteTaskCLICase, slow_test


# TODO actually parse this file to know what extras
# (festival, speect, etc.) are available to test
EXTRA_TESTS = os.path.exists(os.path.join(os.path.expanduser("~"), ".aeneas.conf"))
from aeneas.tests.common import ExecuteTaskCLICase, slow_test, extra_test


@slow_test
Expand Down Expand Up @@ -68,9 +61,8 @@ def test_exec_tts_cache_empty_fragments_pure(self):
0,
)

@extra_test
def test_exec_tts_cache_empty_fragments_festival(self):
if not EXTRA_TESTS:
return
self.execute(
[
("in", "../tools/res/audio.mp3"),
Expand All @@ -82,9 +74,8 @@ def test_exec_tts_cache_empty_fragments_festival(self):
0,
)

@extra_test
def test_exec_tts_cache_empty_fragments_festival_pure(self):
if not EXTRA_TESTS:
return
self.execute(
[
("in", "../tools/res/audio.mp3"),
Expand Down
6 changes: 0 additions & 6 deletions aeneas/tests/test_long_task_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,11 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import os

from aeneas.tests.common import ExecuteTaskCLICase, slow_test
import aeneas.globalfunctions as gf


# TODO actually parse this file to know what extras
# (festival, speect, etc.) are available to test
EXTRA_TESTS = os.path.exists(os.path.join(os.path.expanduser("~"), ".aeneas.conf"))


@slow_test
class TestExecuteTaskCLI(ExecuteTaskCLICase):
def test_exec_is_audio_file_detect_head_max(self):
Expand Down
Loading

0 comments on commit 4c0ed01

Please sign in to comment.