-SIMPLE_CASES = [
- "beginning_backslash",
- "bracketmatch",
- "cantfit",
- "class_blank_parentheses",
- "class_methods_new_line",
- "collections",
- "comments",
- "comments2",
- "comments3",
- "comments4",
- "comments5",
- "comments6",
- "comments7",
- "comments_non_breaking_space",
- "comment_after_escaped_newline",
- "composition",
- "composition_no_trailing_comma",
- "docstring",
- "empty_lines",
- "expression",
- "fmtonoff",
- "fmtonoff2",
- "fmtonoff3",
- "fmtonoff4",
- "fmtskip",
- "fmtskip2",
- "fmtskip3",
- "fmtskip4",
- "fmtskip5",
- "fstring",
- "function",
- "function2",
- "function_trailing_comma",
- "import_spacing",
- "long_strings",
- "long_strings__edge_case",
- "long_strings__regression",
- "numeric_literals_py2",
- "percent_precedence",
- "python2",
- "python2_unicode_literals",
- "remove_parens",
- "slices",
- "string_prefixes",
- "tricky_unicode_symbols",
- "tupleassign",
-]
+
+@pytest.fixture(autouse=True)
+def patch_dump_to_file(request: Any) -> Iterator[None]:
+ with patch("black.dump_to_file", dump_to_stderr):
+ yield
+
+
+def check_file(subdir: str, filename: str, *, data: bool = True) -> None:
+ args, source, expected = read_data_with_mode(subdir, filename, data=data)
+ assert_format(
+ source,
+ expected,
+ args.mode,
+ fast=args.fast,
+ minimum_version=args.minimum_version,
+ )
+ if args.minimum_version is not None:
+ major, minor = args.minimum_version
+ target_version = TargetVersion[f"PY{major}{minor}"]
+ mode = replace(args.mode, target_versions={target_version})
+ assert_format(
+ source, expected, mode, fast=args.fast, minimum_version=args.minimum_version
+ )
+
+
+@pytest.mark.filterwarnings("ignore:invalid escape sequence.*:DeprecationWarning")
+@pytest.mark.parametrize("filename", all_data_cases("cases"))
+def test_simple_format(filename: str) -> None:
+ check_file("cases", filename)
+
+
+# =============== #
+# Unusual cases
+# =============== #