black.assert_equivalent(source, actual)
black.assert_stable(source, actual, line_length=ll)
+ @patch("black.dump_to_file", dump_to_stderr)
+ def test_function2(self) -> None:
+ source, expected = read_data("function2")
+ actual = fs(source)
+ self.assertFormatEqual(expected, actual)
+ black.assert_equivalent(source, actual)
+ black.assert_stable(source, actual, line_length=ll)
+
@patch("black.dump_to_file", dump_to_stderr)
def test_expression(self) -> None:
source, expected = read_data("expression")
black.assert_equivalent(source, actual)
black.assert_stable(source, actual, line_length=ll)
+ @patch("black.dump_to_file", dump_to_stderr)
+ def test_slices(self) -> None:
+ source, expected = read_data("slices")
+ actual = fs(source)
+ self.assertFormatEqual(expected, actual)
+ black.assert_equivalent(source, actual)
+ black.assert_stable(source, actual, line_length=ll)
+
@patch("black.dump_to_file", dump_to_stderr)
def test_comments(self) -> None:
source, expected = read_data("comments")
black.assert_equivalent(source, actual)
black.assert_stable(source, actual, line_length=ll)
+ @patch("black.dump_to_file", dump_to_stderr)
+ def test_remove_empty_parentheses_after_class(self) -> None:
+ source, expected = read_data("class_blank_parentheses")
+ actual = fs(source)
+ self.assertFormatEqual(expected, actual)
+ black.assert_equivalent(source, actual)
+ black.assert_stable(source, actual, line_length=ll)
+
def test_report(self) -> None:
report = black.Report()
out_lines = []
)
self.assertEqual(result.exit_code, 1)
+ def test_no_files(self) -> None:
+ with cache_dir():
+ # Without an argument, black exits with error code 0.
+ result = CliRunner().invoke(black.main, [])
+ self.assertEqual(result.exit_code, 0)
+
def test_read_cache_line_lengths(self) -> None:
with cache_dir() as workspace:
path = (workspace / "file.py").resolve()