X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/aedb4ff7f061b321ea5804bc4fc4943c52c6a786..fc2a16433e7da705793122dd0c66fcde83b305d5:/tests/util.py?ds=sidebyside diff --git a/tests/util.py b/tests/util.py index 8755111..1d76681 100644 --- a/tests/util.py +++ b/tests/util.py @@ -90,12 +90,21 @@ class BlackBaseTestCase(unittest.TestCase): _assert_format_equal(expected, actual) +def all_data_cases(dir_name: str, data: bool = True) -> List[str]: + base_dir = DATA_DIR if data else PROJECT_ROOT + cases_dir = base_dir / dir_name + assert cases_dir.is_dir() + return [f"{dir_name}/{case_path.stem}" for case_path in cases_dir.iterdir()] + + def read_data(name: str, data: bool = True) -> Tuple[str, str]: """read_data('test_name') -> 'input', 'output'""" if not name.endswith((".py", ".pyi", ".out", ".diff")): name += ".py" base_dir = DATA_DIR if data else PROJECT_ROOT - return read_data_from_file(base_dir / name) + case_path = base_dir / name + assert case_path.is_file(), f"{case_path} is not a file." + return read_data_from_file(case_path) def read_data_from_file(file_name: Path) -> Tuple[str, str]: