Skip to content

Improve Dataset test maintainability/readability #1131

@mthrok

Description

@mthrok

In #821, we improved the dataset tests to work on mocked files. In these changes, we applied the pattern to create mock dataset in setUpClass. As we keep improving the test for dataset, the setUpClass gets cluttered and became harder to grasp what's going on, so we should refactor the pattern.

In #1126 we extracted the dataset mocking part into a separate function. We can apply the same pattern to the other tests too. In the end, the initialization should look as simple as,

@classmethod
def setUpClass(cls):
    cls.root_dir = cls.get_base_temp_dir()
    cls.data = get_mock_dataset(cls.root_dir)

with extracted helper function that creates mock data and returns the expected data.

def get_mock_dataset(root_dir):
    ...

Additionally, for CommonVoice, the mock part is extracted, but there are two helper functions what are very similar each other, so we can refactor that part too.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions