diff --git a/fs2/tests/test_chunking.py b/fs2/tests/test_chunking.py index f5399d9..2560015 100644 --- a/fs2/tests/test_chunking.py +++ b/fs2/tests/test_chunking.py @@ -3,7 +3,6 @@ from string import ascii_lowercase from tempfile import TemporaryDirectory from typing import Callable -from unittest import TestCase import torch from everyvoice.config.shared_types import ContactInformation @@ -18,29 +17,28 @@ from ..type_definitions import SynthesizeOutputFormats -class TestDuplicateFilename(TestCase): - def setUp(self): - self.contact = ContactInformation( - contact_name="Test Runner", contact_email="info@everyvoice.ca" - ) - self.output_key = "output" - self.outputs = { - self.output_key: torch.ones([3, 500, 80], device="cpu"), - "duration_prediction": torch.ones([3, 7], device="cpu"), - "tgt_lens": [490, 490, 490], - } - self.batch1 = { - "basename": ["This is a chunk", "This is another chunk", "This is a chunk"], - "raw_text": ["This is a chunk", "This is another chunk", "This is a chunk"], - "text": [ - torch.IntTensor([2, 3, 4, 5, 6, 7, 8], device="cpu"), - torch.IntTensor([2, 3, 4, 5, 6, 7, 8], device="cpu"), - torch.IntTensor([2, 3, 4, 5, 6, 7, 8], device="cpu"), - ], - "speaker": ["S1", "S1", "S1"], - "language": ["L1", "L1", "L1"], - "is_last_input_chunk": [0, 1, 1], - } +class TestDuplicateFilename: + contact = ContactInformation( + contact_name="Test Runner", contact_email="info@everyvoice.ca" + ) + output_key = "output" + outputs = { + output_key: torch.ones([3, 500, 80], device="cpu"), + "duration_prediction": torch.ones([3, 7], device="cpu"), + "tgt_lens": [490, 490, 490], + } + batch1 = { + "basename": ["This is a chunk", "This is another chunk", "This is a chunk"], + "raw_text": ["This is a chunk", "This is another chunk", "This is a chunk"], + "text": [ + torch.IntTensor([2, 3, 4, 5, 6, 7, 8], device="cpu"), + torch.IntTensor([2, 3, 4, 5, 6, 7, 8], device="cpu"), + torch.IntTensor([2, 3, 4, 5, 6, 7, 8], device="cpu"), + ], + "speaker": ["S1", "S1", "S1"], + "language": ["L1", "L1", "L1"], + "is_last_input_chunk": [0, 1, 1], + } def test_duplicate_filename(self): """ @@ -77,28 +75,25 @@ def test_duplicate_filename(self): ) output_dir = writer.save_dir # print(output_dir, *output_dir.glob("**")) # For debugging - self.assertTrue(output_dir.exists()) - self.assertTrue( - ( - output_dir - / "This-is-a-chunkThis--9fc7184d--S1--L1--ckpt=77--v_ckpt=10--pred.wav" - ).exists() - ) - self.assertTrue( - ( - output_dir / "This-is-a-chunk--S1--L1--ckpt=77--v_ckpt=10--pred.wav" - ).exists() - ) + assert output_dir.exists() + assert ( + output_dir + / "This-is-a-chunkThis--9fc7184d--S1--L1--ckpt=77--v_ckpt=10--pred.wav" + ).exists() + assert ( + output_dir / "This-is-a-chunk--S1--L1--ckpt=77--v_ckpt=10--pred.wav" + ).exists() -class ChunkingTestBase(TestCase): +class ChunkingTestBase: + # Type declaractions only, values are injected by setup_class get_test_callback: Callable outputs: dict batch1: dict batch2: dict @classmethod - def setUpClass(cls): + def setup_class(cls): # Define the function that gets the callbacks, get_test_callback with TemporaryDirectory() as tmp_dir: tmp_dir = Path(tmp_dir) @@ -190,7 +185,7 @@ def test_wav_chunks(self): ) output_dir = writer.save_dir # print(output_dir, *output_dir.glob("**")) # For debugging - self.assertTrue(output_dir.exists()) + assert output_dir.exists() # Batch 2 writer = next(iter(writers.values())) @@ -204,19 +199,16 @@ def test_wav_chunks(self): ) # Test that the correctly named files were outputted - self.assertTrue( - (output_dir / "one--S1--L1--ckpt=77--v_ckpt=10--pred.wav").exists() - ) - self.assertTrue( - (output_dir / "twothreefour--S2--L2--ckpt=77--v_ckpt=10--pred.wav").exists() - ) + assert (output_dir / "one--S1--L1--ckpt=77--v_ckpt=10--pred.wav").exists() + assert ( + output_dir / "twothreefour--S2--L2--ckpt=77--v_ckpt=10--pred.wav" + ).exists() # Tests that last_file_written contains the correct most recent filename written # This is important for the demo - self.assertEqual( - (output_dir / "twothreefour--S2--L2--ckpt=77--v_ckpt=10--pred.wav"), - Path(writer.last_file_written), - ) + assert ( + output_dir / "twothreefour--S2--L2--ckpt=77--v_ckpt=10--pred.wav" + ) == Path(writer.last_file_written) # Checks that the files have reasonable lengths output_one = AudioSegment.from_file( @@ -228,7 +220,7 @@ def test_wav_chunks(self): # There are four chunks but two outputs. # Output one contains only one chunk, so output_two should be 3 times longer - self.assertEqual(len(output_one) * 3, len(output_two)) + assert len(output_one) * 3 == len(output_two) class TestWritingSpec(ChunkingTestBase): @@ -250,7 +242,7 @@ def test_spec_chunks(self): ) output_dir = writer.save_dir # print(output_dir, *output_dir.glob("**")) # For debugging - self.assertTrue(output_dir.exists()) + assert output_dir.exists() # Batch 2 writer = next(iter(writers.values())) @@ -264,14 +256,10 @@ def test_spec_chunks(self): ) # Test that the correctly named files were outputted - self.assertTrue( - (output_dir / "one--S1--L1--spec-pred-22050-mel-librosa.pt").exists() - ) - self.assertTrue( - ( - output_dir / "twothreefour--S2--L2--spec-pred-22050-mel-librosa.pt" - ).exists() - ) + assert (output_dir / "one--S1--L1--spec-pred-22050-mel-librosa.pt").exists() + assert ( + output_dir / "twothreefour--S2--L2--spec-pred-22050-mel-librosa.pt" + ).exists() # Checks that the files have reasonable lengths output_one = torch.load( @@ -283,7 +271,7 @@ def test_spec_chunks(self): # There are four chunks but two outputs. # Output one contains only one chunk, so output_two should be 3 times longer - self.assertEqual(output_one.size(-1) * 3, output_two.size(-1)) + assert output_one.size(-1) * 3 == output_two.size(-1) class TestWritingTextGrid(ChunkingTestBase): @@ -305,7 +293,7 @@ def test_textgrid_chunks(self): ) output_dir = writer.save_dir # print(output_dir, *output_dir.glob("**/*")) # For debugging - self.assertTrue(output_dir.exists()) + assert output_dir.exists() # Batch 2 writer = next(iter(writers.values())) @@ -318,12 +306,10 @@ def test_textgrid_chunks(self): _dataloader_idx=1, ) # Test that the correctly named files were outputted - self.assertTrue( - (output_dir / "one--S1--L1--22050-mel-librosa.TextGrid").exists() - ) - self.assertTrue( - (output_dir / "twothreefour--S2--L2--22050-mel-librosa.TextGrid").exists() - ) + assert (output_dir / "one--S1--L1--22050-mel-librosa.TextGrid").exists() + assert ( + output_dir / "twothreefour--S2--L2--22050-mel-librosa.TextGrid" + ).exists() # Check that the correct words were added to the first TextGrid tg = TextGrid( @@ -333,11 +319,11 @@ def test_textgrid_chunks(self): phones = [interval[2] for interval in tiers[0].get_all_intervals()] for phone, char in zip(list(phones), list("one")): - self.assertEqual(phone, char) + assert phone == char words = tiers[2].get_all_intervals() - self.assertEqual(len(words), 1) - self.assertEqual(words[0][2], "one") + assert len(words) == 1 + assert words[0][2] == "one" # Check that the correct words were added to the second TextGrid tg = TextGrid( @@ -347,17 +333,17 @@ def test_textgrid_chunks(self): phones = [interval[2] for interval in tiers[0].get_all_intervals()] for phone, char in zip(list(phones), list("twothreefour")): - self.assertEqual(phone, char) + assert phone == char words = tiers[2].get_all_intervals() - self.assertEqual(len(words), 3) - self.assertEqual(words[0][2], "two") - self.assertEqual(words[1][2], "three") - self.assertEqual(words[2][2], "four") + assert len(words) == 3 + assert words[0][2] == "two" + assert words[1][2] == "three" + assert words[2][2] == "four" class TestWritingReadAlongXML(ChunkingTestBase): - def test_writing_readalong(self): + def test_writing_readalong(self, subtests): writers = self.get_test_callback([SynthesizeOutputFormats.readalong_xml]) # Batch 1 @@ -372,7 +358,7 @@ def test_writing_readalong(self): ) output_dir = writer.save_dir - self.assertTrue(output_dir.exists()) + assert output_dir.exists() # Batch 2 writer = next(iter(writers.values())) @@ -392,17 +378,17 @@ def test_writing_readalong(self): output_dir / "twothreefour--S2--L2--22050-mel-librosa.readalong", ) for output_file in output_files: - with self.subTest(output_file=output_file): - self.assertTrue(output_file.exists()) + with subtests.test(output_file=output_file): + assert output_file.exists() with open(output_file, "r", encoding="utf8") as f: readalong = f.read() # print(readalong) - self.assertIn(" None: - super().setUp() - self.runner = CliRunner() - self.subcommands = ( - "benchmark", - "preprocess", - "synthesize", - "train", - ) + subcommands = ("benchmark", "preprocess", "synthesize", "train") def test_check_data(self): filelist = generic_psv_filelist_reader(TEST_DATA_DIR / "metadata.psv") checked_data = check_data_from_filelist( self.preprocessor, filelist, heavy_objective_evaluation=True ) - self.assertIn("pesq", checked_data[0]) - self.assertIn("stoi", checked_data[0]) - self.assertIn("si_sdr", checked_data[0]) - self.assertGreater(checked_data[0]["pesq"], 3.0) - self.assertLess(checked_data[0]["pesq"], 5.0) - self.assertAlmostEqual(checked_data[0]["duration"], 5.17, 2) - - def test_commands_present(self): + assert "pesq" in checked_data[0] + assert "stoi" in checked_data[0] + assert "si_sdr" in checked_data[0] + assert checked_data[0]["pesq"] > 3.0 + assert checked_data[0]["pesq"] < 5.0 + assert checked_data[0]["duration"] == pytest.approx(5.17, abs=0.01) + + def test_commands_present(self, subtests): """ Each subcommand is present in the the command's help message. """ result = self.runner.invoke(app, ["--help"]) for command in self.subcommands: - with self.subTest(msg=f"Looking for {command}"): - self.assertIn(command, result.stdout) + with subtests.test(msg=f"Looking for {command}"): + assert command in result.stdout - def test_command_help_messages(self): + def test_command_help_messages(self, subtests): """ Each subcommand has its help message. """ for subcommand in self.subcommands: - with self.subTest(msg=f"Looking for {subcommand}'s help"): + with subtests.test(msg=f"Looking for {subcommand}'s help"): result = self.runner.invoke(app, [subcommand, "--help"]) - self.assertEqual(result.exit_code, 0) + assert result.exit_code == 0 result = self.runner.invoke(app, [subcommand, "-h"]) - self.assertEqual(result.exit_code, 0) + assert result.exit_code == 0 -class MiscTests(TestCase): +class TestMisc: def test_version_sync(self): """ Ensure fs2 and everyvoice versions are in sync. @@ -514,8 +497,6 @@ def test_version_sync(self): from .._version import VERSION as fs2_version - self.assertEqual( - ev_version, - fs2_version, - "Version mismatch between EveryVoice and FastSpeech2_lightning", - ) + assert ( + ev_version == fs2_version + ), "Version mismatch between EveryVoice and FastSpeech2_lightning" diff --git a/fs2/tests/test_loading.py b/fs2/tests/test_loading.py index da1d0c6..6820452 100644 --- a/fs2/tests/test_loading.py +++ b/fs2/tests/test_loading.py @@ -1,10 +1,10 @@ import tempfile from pathlib import Path -from unittest import TestCase from everyvoice.config.shared_types import ContactInformation from everyvoice.config.type_definitions import DatasetTextRepresentation from everyvoice.text.lookups import LookupTable +from pytest import raises from ..cli.synthesize import load_data_from_filelist from ..config import FastSpeech2Config @@ -14,14 +14,11 @@ TEXT_TO_SPEC_CONFIG_FILENAME_PREFIX = "everyvoice-text-to-spec" -class TestLoadingModel(TestCase): +class TestLoadingModel: """Test loading models""" data_dir = Path(__file__).parent / "data" - - def setUp(self) -> None: - super().setUp() - self.config_dir = self.data_dir / "config" + config_dir = data_dir / "config" def test_wrong_model_type(self): """ @@ -60,16 +57,16 @@ def test_wrong_model_type(self): ckpt_fn = tmpdir_str + "/checkpoint.ckpt" trainer.save_checkpoint(ckpt_fn) m = torch.load(ckpt_fn, weights_only=True) - self.assertIn("model_info", m.keys()) + assert "model_info" in m.keys() m["model_info"]["name"] = "BAD_TYPE" torch.save(m, ckpt_fn) m = torch.load(ckpt_fn, weights_only=True) - self.assertIn("model_info", m.keys()) - self.assertEqual(m["model_info"]["name"], "BAD_TYPE") - # self.assertEqual(m["model_info"]["version"], "1.0") - with self.assertRaisesRegex( + assert "model_info" in m.keys() + assert m["model_info"]["name"] == "BAD_TYPE" + # assert m["model_info"]["version"] == "1.0" + with raises( TypeError, - r"Wrong model type \(BAD_TYPE\), we are expecting a 'FastSpeech2' model", + match=r"Wrong model type \(BAD_TYPE\), we are expecting a 'FastSpeech2' model", ): FastSpeech2.load_from_checkpoint(ckpt_fn) @@ -113,12 +110,10 @@ def test_wrong_model_version(self): ckpt_fn = tmpdir_str + "/checkpoint.ckpt" trainer.save_checkpoint(ckpt_fn) m = torch.load(ckpt_fn, weights_only=True) - self.assertIn("model_info", m.keys()) - self.assertEqual(m["model_info"]["name"], FastSpeech2.__name__) - self.assertEqual(m["model_info"]["version"], BAD_VERSION) - with self.assertRaisesRegex( - InvalidVersion, r"Invalid version: 'BAD_VERSION'" - ): + assert "model_info" in m.keys() + assert m["model_info"]["name"] == FastSpeech2.__name__ + assert m["model_info"]["version"] == BAD_VERSION + with raises(InvalidVersion, match=r"Invalid version: 'BAD_VERSION'"): FastSpeech2.load_from_checkpoint(ckpt_fn) def test_newer_model_version(self): @@ -160,24 +155,21 @@ def test_newer_model_version(self): ckpt_fn = tmpdir_str + "/checkpoint.ckpt" trainer.save_checkpoint(ckpt_fn) m = torch.load(ckpt_fn, weights_only=True) - self.assertIn("model_info", m.keys()) - self.assertEqual(m["model_info"]["name"], FastSpeech2.__name__) - self.assertEqual(m["model_info"]["version"], BAD_VERSION) - with self.assertRaisesRegex( + assert "model_info" in m.keys() + assert m["model_info"]["name"] == FastSpeech2.__name__ + assert m["model_info"]["version"] == BAD_VERSION + with raises( ValueError, - r"Your model was created with a newer version of EveryVoice, please update your software.", + match=r"Your model was created with a newer version of EveryVoice, please update your software.", ): FastSpeech2.load_from_checkpoint(ckpt_fn) -class TestLoadingConfig(TestCase): +class TestLoadingConfig: """Test loading configurations""" data_dir = Path(__file__).parent / "data" - - def setUp(self) -> None: - super().setUp() - self.config_dir = self.data_dir / "config" + config_dir = data_dir / "config" def test_config_versionless(self): """ @@ -189,9 +181,9 @@ def test_config_versionless(self): ).model_dump() del arguments["VERSION"] - self.assertNotIn("VERSION", arguments) + assert "VERSION" not in arguments c = FastSpeech2Config(**arguments) - self.assertEqual(c.VERSION, "1.0") + assert c.VERSION == "1.0" def test_config_newer_version(self): """ @@ -204,9 +196,9 @@ def test_config_newer_version(self): NEWER_VERSION = "100.0" reference.VERSION = NEWER_VERSION - with self.assertRaisesRegex( + with raises( ValueError, - r"Your config was created with a newer version of EveryVoice, please update your software.", + match=r"Your config was created with a newer version of EveryVoice, please update your software.", ): FastSpeech2Config(**reference.model_dump()) @@ -223,7 +215,7 @@ def __init__(self): self.speaker2id: LookupTable = {} -class TestLoadingData(TestCase): +class TestLoadingData: def write_and_load(self, file_contents: str): with tempfile.TemporaryDirectory() as tmpdir: @@ -239,12 +231,12 @@ def write_and_load(self, file_contents: str): def test_load_oneline(self): data = self.write_and_load("this is a test\n") - self.assertEqual(len(data), 1) + assert len(data) == 1 def test_load_twolines(self): data = self.write_and_load("test line 1\ntest line 2\n") - self.assertEqual(len(data), 2) + assert len(data) == 2 def test_load_psv(self): data = self.write_and_load("characters|language\nfoo|eng\nbar|eng\nbaz|fra\n") - self.assertEqual(len(data), 3) + assert len(data) == 3 diff --git a/fs2/tests/test_writing_callbacks.py b/fs2/tests/test_writing_callbacks.py index 01ea4b6..0ad398a 100644 --- a/fs2/tests/test_writing_callbacks.py +++ b/fs2/tests/test_writing_callbacks.py @@ -1,6 +1,6 @@ +import re from pathlib import Path from tempfile import TemporaryDirectory -from unittest import TestCase import torch from everyvoice.config.shared_types import ContactInformation @@ -23,7 +23,7 @@ pass -class TestTruncateBasename(TestCase): +class TestTruncateBasename: """ Testing truncate_basename(). """ @@ -33,7 +33,7 @@ def test_short_name(self): Short utterances should produce file names that are not truncated. """ output = truncate_basename("Short utterance") - self.assertEqual(output, "Short-utterance") + assert output == "Short-utterance" def test_long_name(self): """ @@ -41,8 +41,8 @@ def test_long_name(self): should have a sha1 in case two utterances have the same prefix. """ output = truncate_basename("A utterance that is too long") - self.assertEqual(len(output), BASENAME_MAX_LENGTH + 1 + 8) - self.assertEqual(output, "A-utterance-that-is--d607fba8") + assert len(output) == BASENAME_MAX_LENGTH + 1 + 8 + assert output == "A-utterance-that-is--d607fba8" def test_limit(self): """ @@ -50,8 +50,8 @@ def test_limit(self): """ input = "A" * BASENAME_MAX_LENGTH output = truncate_basename(input) - self.assertEqual(len(output), BASENAME_MAX_LENGTH) - self.assertEqual(output, input) + assert len(output) == BASENAME_MAX_LENGTH + assert output == input def test_limit_plus_one(self): """ @@ -59,7 +59,7 @@ def test_limit_plus_one(self): """ input = "A" * (BASENAME_MAX_LENGTH + 1) output = truncate_basename(input) - self.assertEqual(len(output), BASENAME_MAX_LENGTH + 1 + 8) + assert len(output) == BASENAME_MAX_LENGTH + 1 + 8 def test_same_prefix_different_names(self): """ @@ -70,50 +70,49 @@ def test_same_prefix_different_names(self): input2 = prefix + "2" output1 = truncate_basename(input1) output2 = truncate_basename(input2) - self.assertNotEqual(output1, output2) - self.assertRegex(output1, prefix + r"-[0-9A-Fa-f]{8}") - self.assertRegex(output2, prefix + r"-[0-9A-Fa-f]{8}") - - -class WritingTestBase(TestCase): - @classmethod - def setUpClass(cls): - cls.contact = ContactInformation( - contact_name="Test Runner", contact_email="info@everyvoice.ca" - ) - cls.output_key = "output" - cls.outputs = { - cls.output_key: torch.ones([2, 500, 80], device="cpu"), - "duration_prediction": torch.ones([2, 7], device="cpu"), - "tgt_lens": [ - 90, - 490, - ], - } - cls.batch = { - "basename": [ - "short", - "This-utterance-is-wa-dcae74b8", - ], - "duration_control": [1.0, 1.0], - "raw_text": [ - "short", - "This utterance is way too long", - ], - "text": [ - torch.IntTensor([2, 3, 4, 5, 6, 7, 8], device="cpu"), - torch.IntTensor([2, 3, 4, 5, 6, 7, 8], device="cpu"), - ], - "speaker": [ - "spk1", - "spk2", - ], - "language": [ - "lngA", - "lngB", - ], - "is_last_input_chunk": [1, 1], - } + assert output1 != output2 + pattern = re.compile(prefix + r"-[0-9A-Fa-f]{8}") + assert pattern.search(output1), f"{output1} does not match {pattern}" + assert pattern.search(output2), f"{output1} does not match {pattern}" + + +class WritingTestBase: + contact = ContactInformation( + contact_name="Test Runner", contact_email="info@everyvoice.ca" + ) + output_key = "output" + outputs = { + output_key: torch.ones([2, 500, 80], device="cpu"), + "duration_prediction": torch.ones([2, 7], device="cpu"), + "tgt_lens": [ + 90, + 490, + ], + } + batch = { + "basename": [ + "short", + "This-utterance-is-wa-dcae74b8", + ], + "duration_control": [1.0, 1.0], + "raw_text": [ + "short", + "This utterance is way too long", + ], + "text": [ + torch.IntTensor([2, 3, 4, 5, 6, 7, 8], device="cpu"), + torch.IntTensor([2, 3, 4, 5, 6, 7, 8], device="cpu"), + ], + "speaker": [ + "spk1", + "spk2", + ], + "language": [ + "lngA", + "lngB", + ], + "is_last_input_chunk": [1, 1], + } class TestWritingSpec(WritingTestBase): @@ -147,18 +146,14 @@ def test_filenames_not_truncated(self): ) output_dir = writer.save_dir # print(output_dir, *output_dir.glob("**/*")) # For debugging - self.assertTrue(output_dir.exists()) - self.assertTrue( - ( - output_dir / "short--spk1--lngA--spec-pred-22050-mel-librosa.pt" - ).exists() - ) - self.assertTrue( - ( - output_dir - / "This-utterance-is-wa-dcae74b8--spk2--lngB--spec-pred-22050-mel-librosa.pt" - ).exists() - ) + assert output_dir.exists() + assert ( + output_dir / "short--spk1--lngA--spec-pred-22050-mel-librosa.pt" + ).exists() + assert ( + output_dir + / "This-utterance-is-wa-dcae74b8--spk2--lngB--spec-pred-22050-mel-librosa.pt" + ).exists() class TestWritingTextGrid(WritingTestBase): @@ -192,16 +187,14 @@ def test_filenames_not_truncated(self): ) output_dir = writer.save_dir # print(output_dir, *output_dir.glob("**/*")) # For debugging - self.assertTrue(output_dir.exists()) - self.assertTrue( - (output_dir / "short--spk1--lngA--22050-mel-librosa.TextGrid").exists() - ) - self.assertTrue( - ( - output_dir - / "This-utterance-is-wa-dcae74b8--spk2--lngB--22050-mel-librosa.TextGrid" - ).exists() - ) + assert output_dir.exists() + assert ( + output_dir / "short--spk1--lngA--22050-mel-librosa.TextGrid" + ).exists() + assert ( + output_dir + / "This-utterance-is-wa-dcae74b8--spk2--lngB--22050-mel-librosa.TextGrid" + ).exists() tg = TextGrid( file_path=( output_dir @@ -209,11 +202,11 @@ def test_filenames_not_truncated(self): ) ) tiers = list(tg.get_tiers()) - self.assertEqual(tiers[0].name, "phones") - self.assertEqual(tiers[1].name, "phone annotations") - self.assertEqual(tiers[2].name, "words") - self.assertEqual(tiers[3].name, "word annotations") - self.assertEqual(tiers[2].intervals[0][2], "This") + assert tiers[0].name == "phones" + assert tiers[1].name == "phone annotations" + assert tiers[2].name == "words" + assert tiers[3].name == "word annotations" + assert tiers[2].intervals[0][2] == "This" class TestWritingReadAlong(WritingTestBase): @@ -221,7 +214,7 @@ class TestWritingReadAlong(WritingTestBase): Testing the callback that writes .readalong files. """ - def test_writing_readalong(self): + def test_writing_readalong(self, subtests): with TemporaryDirectory() as tmp_dir: tmp_dir = Path(tmp_dir) writers = get_synthesis_output_callbacks( @@ -250,13 +243,13 @@ def test_writing_readalong(self): / "This-utterance-is-wa-dcae74b8--spk2--lngB--22050-mel-librosa.readalong", ) for output_file in output_files: - with self.subTest(output_file=output_file): - self.assertTrue(output_file.exists()) + with subtests.test(output_file=output_file): + assert output_file.exists() with open(output_file, "r", encoding="utf8") as f: readalong = f.read() # print(readalong) - self.assertIn("