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

Method test_cache_key

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

Source from the content-addressed store, hash-verified

2481 assert two.is_changed(path)
2482
2483 def test_cache_key(self) -> None:
2484 # Test that all members of the mode enum affect the cache key.
2485 for field in fields(Mode):
2486 values: list[Any]
2487 if field.name == "target_versions":
2488 values = [
2489 {TargetVersion.PY312},
2490 {TargetVersion.PY313},
2491 ]
2492 elif field.name == "python_cell_magics":
2493 values = [{"magic1"}, {"magic2"}]
2494 elif field.name == "enabled_features":
2495 # If you are looking to remove one of these features, just
2496 # replace it with any other feature.
2497 values = [
2498 {Preview.wrap_comprehension_in},
2499 {Preview.string_processing},
2500 ]
2501 elif field.type is bool:
2502 values = [True, False]
2503 elif field.type is int:
2504 values = [1, 2]
2505 else:
2506 raise AssertionError(
2507 f"Unhandled field type: {field.type} for field {field.name}"
2508 )
2509 modes = [replace(DEFAULT_MODE, **{field.name: value}) for value in values]
2510 keys = [mode.get_cache_key() for mode in modes]
2511 assert len(set(keys)) == len(modes)
2512
2513
2514def assert_collected_sources(

Callers

nothing calls this directly

Calls 2

replaceFunction · 0.85
get_cache_keyMethod · 0.80

Tested by

no test coverage detected