Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change parameterized testing system to be compatible with unittest #712

Merged
merged 2 commits into from
Jun 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions test/common_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ def define_test_suites(
scope[t.__name__] = t


def common_test_class_parameters(
dtypes: Iterable[str] = ("float32", "float64"),
devices: Iterable[str] = ("cpu", "cuda"),
):
for device in devices:
for dtype in dtypes:
yield {"device": torch.device(device), "dtype": getattr(torch, dtype)}


def get_whitenoise(
*,
sample_rate: int = 16000,
Expand Down
16 changes: 14 additions & 2 deletions test/torchscript_consistency_cpu_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
from .common_utils import define_test_suites
from parameterized import parameterized_class

from .common_utils import TestCase, common_test_class_parameters
from .torchscript_consistency_impl import Functional, Transforms


define_test_suites(globals(), [Functional, Transforms], devices=['cpu'])
parameters = list(common_test_class_parameters(devices=['cpu']))


@parameterized_class(parameters)
class TestFunctional(Functional, TestCase):
pass


@parameterized_class(parameters)
class TestTransforms(Transforms, TestCase):
pass