blob: 5d4633dfea0e4452bcf15a0ea7ca52f618ecae4f [file] [log] [blame] [edit]
#!/usr/bin/env python3
# Copyright 2022 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Add an interface class for defining TestCase Enums."""
from __future__ import annotations
from enum import Enum
class TestCase(Enum):
...
# The `value` should be a tuple with first value being the description.
# Any additional info can be placed in extra tuple positions.
#
# Example:
# One = ("One's description", ...)
@classmethod
def all(cls) -> list[TestCase]:
return [level for level in cls]
@classmethod
def all_values(cls, s=slice(None)) -> list[str]:
return [level.value[s] for level in cls]
def __str__(self) -> str:
return self.name
def description(self) -> str:
"""Get the description for the given test case."""
assert type(self.value) == tuple
assert len(self.value) >= 1
assert type(self.value[0]) == str
return self.value[0]
def extra(self) -> tuple:
"""Get extra value tuple info."""
assert type(self.value) == tuple
assert len(self.value) >= 1
assert type(self.value[0]) == str
return self.value[1:]