All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 from unittest.mock import patch
5 from parameterized import parameterized
7 from tests.util import (
17 "beginning_backslash",
19 "class_blank_parentheses",
20 "class_methods_new_line",
28 "comments_non_breaking_space",
29 "comment_after_escaped_newline",
31 "composition_no_trailing_comma",
47 "function_trailing_comma",
52 "tricky_unicode_symbols",
57 "numeric_literals_py2",
59 "python2_unicode_literals",
62 EXPERIMENTAL_STRING_PROCESSING_CASES = [
66 "long_strings__edge_case",
67 "long_strings__regression",
73 "src/black/__init__.py",
74 "src/black/__main__.py",
75 "src/black/brackets.py",
77 "src/black/comments.py",
78 "src/black/concurrency.py",
82 "src/black/linegen.py",
86 "src/black/numerics.py",
87 "src/black/output.py",
88 "src/black/parsing.py",
89 "src/black/report.py",
91 "src/black/strings.py",
93 "src/blackd/__init__.py",
94 "src/blib2to3/pygram.py",
95 "src/blib2to3/pytree.py",
96 "src/blib2to3/pgen2/conv.py",
97 "src/blib2to3/pgen2/driver.py",
98 "src/blib2to3/pgen2/grammar.py",
99 "src/blib2to3/pgen2/literals.py",
100 "src/blib2to3/pgen2/parse.py",
101 "src/blib2to3/pgen2/pgen.py",
102 "src/blib2to3/pgen2/tokenize.py",
103 "src/blib2to3/pgen2/token.py",
105 "tests/test_black.py",
106 "tests/test_blackd.py",
107 "tests/test_format.py",
108 "tests/test_primer.py",
115 class TestSimpleFormat(BlackBaseTestCase):
116 @parameterized.expand(SIMPLE_CASES_PY2)
118 @patch("black.dump_to_file", dump_to_stderr)
119 def test_simple_format_py2(self, filename: str) -> None:
120 self.check_file(filename, DEFAULT_MODE)
122 @parameterized.expand(SIMPLE_CASES)
123 @patch("black.dump_to_file", dump_to_stderr)
124 def test_simple_format(self, filename: str) -> None:
125 self.check_file(filename, DEFAULT_MODE)
127 @parameterized.expand(EXPERIMENTAL_STRING_PROCESSING_CASES)
128 @patch("black.dump_to_file", dump_to_stderr)
129 def test_experimental_format(self, filename: str) -> None:
130 self.check_file(filename, black.Mode(experimental_string_processing=True))
132 @parameterized.expand(SOURCES)
133 @patch("black.dump_to_file", dump_to_stderr)
134 def test_source_is_formatted(self, filename: str) -> None:
135 path = THIS_DIR.parent / filename
136 self.check_file(str(path), DEFAULT_MODE, data=False)
138 def check_file(self, filename: str, mode: black.Mode, *, data: bool = True) -> None:
139 source, expected = read_data(filename, data=data)
140 actual = fs(source, mode=mode)
141 self.assertFormatEqual(expected, actual)
143 black.assert_equivalent(source, actual)
144 black.assert_stable(source, actual, mode)