def assert_file_has_working_code_snippets(path: str, assume_import: bool):
    """Checks that code snippets in a file actually run."""

    with open(path, encoding='utf-8') as f:
        content = f.read()

    # Find snippets of code, and execute them. They should finish.
    if path.endswith('.md'):
        overrides = find_markdown_test_overrides(content)
        content = apply_overrides(content, overrides)
        snippets = find_markdown_code_snippets(content)
    assert_code_snippets_run_in_sequence(snippets, assume_import)
Checks that code snippets in a file actually run.
dev_tools/snippets_test.py