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

Method test_no_cache_when_writeback_diff

tests/test_black.py:2265–2281  ·  view source on GitHub ↗
(self, color: bool)

Source from the content-addressed store, hash-verified

2263 @pytest.mark.incompatible_with_mypyc
2264 @pytest.mark.parametrize("color", [False, True], ids=["no-color", "with-color"])
2265 def test_no_cache_when_writeback_diff(self, color: bool) -> None:
2266 mode = DEFAULT_MODE
2267 with cache_dir() as workspace:
2268 src = (workspace / "test.py").resolve()
2269 src.write_text("print('hello')", encoding="utf-8")
2270 with (
2271 patch.object(black.Cache, "read") as read_cache,
2272 patch.object(black.Cache, "write") as write_cache,
2273 ):
2274 cmd = [str(src), "--diff"]
2275 if color:
2276 cmd.append("--color")
2277 invokeBlack(cmd)
2278 cache_file = get_cache_file(mode)
2279 assert cache_file.exists() is False
2280 read_cache.assert_called_once()
2281 write_cache.assert_not_called()
2282
2283 @pytest.mark.parametrize("color", [False, True], ids=["no-color", "with-color"])
2284 @event_loop()

Callers

nothing calls this directly

Calls 4

get_cache_fileFunction · 0.90
cache_dirFunction · 0.85
invokeBlackFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected