6262
6363import cirq
6464
65+ DOCS_FOLDER = pathlib .Path (__file__ ).parent .parent / 'docs'
6566
6667def test_can_run_readme_code_snippets ():
6768 # Get the contents of the README.md file at the project root.
@@ -72,15 +73,18 @@ def test_can_run_readme_code_snippets():
7273
7374
7475def find_docs_code_snippets_paths () -> Iterator [str ]:
75- docs_folder = pathlib .Path (__file__ ).parent
76- for filename in docs_folder .rglob ('*.md' ):
77- yield str (filename .relative_to (docs_folder ))
76+ exclude_path = ['hardware' , 'google' ]
77+ for filename in DOCS_FOLDER .rglob ('*.md' ):
78+ # Skip files under hardware and google, since there are a lot of
79+ # code snippets import cirq_* which can't resolved in the test.
80+ path = str (filename .relative_to (DOCS_FOLDER ))
81+ if not any (path .startswith (excluded ) for excluded in exclude_path ):
82+ yield path
7883
7984
8085@pytest .mark .parametrize ('path' , find_docs_code_snippets_paths ())
8186def test_can_run_docs_code_snippets (path ):
82- docs_folder = os .path .dirname (__file__ )
83- assert_file_has_working_code_snippets (os .path .join (docs_folder , path ), assume_import = True )
87+ assert_file_has_working_code_snippets (os .path .join (DOCS_FOLDER , path ), assume_import = True )
8488
8589
8690def find_code_snippets (pattern : str , content : str ) -> list [tuple [str , int ]]:
0 commit comments