MCPcopy
hub / github.com/psf/black / test_skip_magic_trailing_comma

Method test_skip_magic_trailing_comma

tests/test_black.py:401–429  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

399 self.assertEqual(test_file.read_bytes(), expected)
400
401 def test_skip_magic_trailing_comma(self) -> None:
402 source, _ = read_data("cases", "expression")
403 expected, _ = read_data(
404 "miscellaneous", "expression_skip_magic_trailing_comma.diff"
405 )
406 tmp_file = Path(black.dump_to_file(source))
407 diff_header = re.compile(
408 rf"{re.escape(str(tmp_file))}\t\d\d\d\d-\d\d-\d\d "
409 r"\d\d:\d\d:\d\d\.\d\d\d\d\d\d\+\d\d:\d\d"
410 )
411 try:
412 result = BlackRunner().invoke(
413 black.main, ["-C", "--diff", str(tmp_file), f"--config={EMPTY_CONFIG}"]
414 )
415 self.assertEqual(result.exit_code, 0)
416 finally:
417 os.unlink(tmp_file)
418 actual = result.stdout
419 actual = diff_header.sub(DETERMINISTIC_HEADER, actual)
420 actual = actual.rstrip() + "\n" # the diff output has a trailing space
421 if expected != actual:
422 dump = black.dump_to_file(actual)
423 msg = (
424 "Expected diff isn't equal to the actual. If you made changes to"
425 " expression.py and this is an anticipated difference, overwrite"
426 " tests/data/miscellaneous/expression_skip_magic_trailing_comma.diff"
427 f" with {dump}"
428 )
429 self.assertEqual(expected, actual, msg)
430
431 @patch("black.dump_to_file", dump_to_stderr)
432 def test_python37(self) -> None:

Callers

nothing calls this directly

Calls 2

read_dataFunction · 0.90
BlackRunnerClass · 0.85

Tested by

no test coverage detected