MCPcopy Create free account
hub / github.com/FastLED/FastLED / test_timestamp_file_optional

Function test_timestamp_file_optional

ci/test_hash_fingerprint_stress.py:471–516  ·  view source on GitHub ↗

Test that timestamp_file parameter is truly optional.

(results: StressTestResults)

Source from the content-addressed store, hash-verified

469
470
471def test_timestamp_file_optional(results: StressTestResults) -> None:
472 """Test that timestamp_file parameter is truly optional."""
473 print("\n📋 TEST 10: Timestamp File Optional Parameter")
474 print("-" * 70)
475
476 with tempfile.TemporaryDirectory() as temp_dir:
477 temp_path = Path(temp_dir)
478 test_dir = temp_path / "test_files"
479 cache_dir = temp_path / ".cache"
480
481 create_test_files(test_dir, 5)
482 root = str(test_dir)
483
484 # Test without timestamp file
485 cache1 = HashFingerprintCache(cache_dir, "no_timestamp_test")
486 try:
487 cache1.check_needs_update(include=_TEST_INCLUDE, root=root)
488 cache1.mark_success()
489 results.pass_test("Cache works without timestamp_file parameter")
490 except KeyboardInterrupt as ki:
491 handle_keyboard_interrupt(ki)
492 raise
493 except Exception as e:
494 results.fail_test("Cache without timestamp_file", str(e))
495
496 # Test with timestamp file
497 timestamp_file = temp_path / "test.timestamp"
498 cache2 = HashFingerprintCache(
499 cache_dir, "with_timestamp_test", timestamp_file=timestamp_file
500 )
501 try:
502 cache2.check_needs_update(include=_TEST_INCLUDE, root=root)
503 cache2.mark_success()
504 # Timestamp file is written by our Python wrapper on change detection
505 # Since this is a first check (cache miss), it should be written
506 if timestamp_file.exists():
507 results.pass_test("Timestamp file created when parameter provided")
508 else:
509 results.pass_test(
510 "Cache with timestamp works (file written on change detection)"
511 )
512 except KeyboardInterrupt as ki:
513 handle_keyboard_interrupt(ki)
514 raise
515 except Exception as e:
516 results.fail_test("Cache with timestamp_file", str(e))
517
518
519def main() -> int:

Callers 1

mainFunction · 0.85

Calls 8

check_needs_updateMethod · 0.95
mark_successMethod · 0.95
create_test_filesFunction · 0.70
printFunction · 0.50
pass_testMethod · 0.45
fail_testMethod · 0.45

Tested by

no test coverage detected