-
Notifications
You must be signed in to change notification settings - Fork 313
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MAINT: use a function to test the warnings of the CI doc build (#1002)
Co-authored-by: Chris Holdgraf <[email protected]>
- Loading branch information
Showing
7 changed files
with
112 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,7 @@ test = [ | |
coverage = [ | ||
"pytest-cov", | ||
"codecov", | ||
"colorama", | ||
"pydata-sphinx-theme[test]", | ||
] | ||
dev = [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
from pathlib import Path | ||
import sys | ||
|
||
from colorama import Fore, init | ||
|
||
# init colors for all plateforms | ||
init() | ||
|
||
|
||
def check_warnings(file): | ||
""" | ||
Check the list of warnings produced by the GitHub CI tests | ||
raise errors if there are unexpected ones and/or if some are missing | ||
Args: | ||
file (pathlib.Path): the path to the generated warning.txt file from | ||
the CI build | ||
Return: | ||
0 if the warnings are all there | ||
1 if some warning are not registered or unexpected | ||
""" | ||
|
||
# print some log | ||
print("\n=== Sphinx Warnings test ===\n") | ||
|
||
# find the file where all the known warnings are stored | ||
warning_file = Path(__file__).parent / "warning_list.txt" | ||
|
||
test_warnings = file.read_text().strip().split("\n") | ||
ref_warnings = warning_file.read_text().strip().split("\n") | ||
|
||
print( | ||
f'Checking build warnings in file: "{file}" and comparing to expected ' | ||
f'warnings defined in "{warning_file}"\n\n' | ||
) | ||
|
||
# find all the missing warnings | ||
missing_warnings = [] | ||
for wa in ref_warnings: | ||
index = [i for i, twa in enumerate(test_warnings) if wa in twa] | ||
if len(index) == 0: | ||
missing_warnings += [wa] | ||
print(f"{Fore.YELLOW}Warning was not raised: {Fore.RESET}{wa}\n") | ||
else: | ||
test_warnings.pop(index[0]) | ||
|
||
# the remaining one are unexpected | ||
for twa in test_warnings: | ||
print(f"{Fore.YELLOW}Unexpected warning: {Fore.RESET}{twa}\n") | ||
|
||
return len(missing_warnings) != 0 or len(test_warnings) != 0 | ||
|
||
|
||
if __name__ == "__main__": | ||
|
||
# cast the file to path and resolve to an absolute one | ||
file = Path.cwd() / "warnings.txt" | ||
|
||
# execute the test | ||
sys.exit(check_warnings(file)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
WARNING: undefined label: 'groupby.transform' | ||
WARNING: image file not readable: _static/gallery/pandas.png | ||
WARNING: image file not readable: _static/gallery/numpy.png | ||
WARNING: image file not readable: _static/gallery/scipy.png | ||
WARNING: image file not readable: _static/gallery/bokeh.png | ||
WARNING: image file not readable: _static/gallery/cupy.png | ||
WARNING: image file not readable: _static/gallery/pyvista.png | ||
WARNING: image file not readable: _static/gallery/mne-python.png | ||
WARNING: image file not readable: _static/gallery/networkx.png | ||
WARNING: image file not readable: _static/gallery/fairlearn.png | ||
WARNING: image file not readable: _static/gallery/jupyter_book.png | ||
WARNING: image file not readable: _static/gallery/binder.png | ||
WARNING: image file not readable: _static/gallery/jupyter.png | ||
WARNING: image file not readable: _static/gallery/megengine.png | ||
WARNING: image file not readable: _static/gallery/feature-engine.png | ||
WARNING: image file not readable: _static/gallery/arviz.png | ||
WARNING: image file not readable: _static/gallery/sepal.png | ||
WARNING: image file not readable: _static/gallery/enoslib.png | ||
WARNING: autosummary: stub file not found 'urllib.parse.DefragResult.count'. Check your autosummary_generate setting. | ||
WARNING: autosummary: stub file not found 'urllib.parse.DefragResult.index'. Check your autosummary_generate setting. | ||
WARNING: autosummary: stub file not found 'urllib.parse.DefragResultBytes.count'. Check your autosummary_generate setting. | ||
WARNING: autosummary: stub file not found 'urllib.parse.DefragResultBytes.index'. Check your autosummary_generate setting. | ||
WARNING: autosummary: stub file not found 'urllib.parse.ParseResult.count'. Check your autosummary_generate setting. | ||
WARNING: autosummary: stub file not found 'urllib.parse.ParseResult.index'. Check your autosummary_generate setting. | ||
WARNING: autosummary: stub file not found 'urllib.parse.ParseResultBytes.count'. Check your autosummary_generate setting. | ||
WARNING: autosummary: stub file not found 'urllib.parse.ParseResultBytes.index'. Check your autosummary_generate setting. | ||
WARNING: autosummary: stub file not found 'urllib.parse.SplitResult.count'. Check your autosummary_generate setting. | ||
WARNING: autosummary: stub file not found 'urllib.parse.SplitResult.index'. Check your autosummary_generate setting. | ||
WARNING: autosummary: stub file not found 'urllib.parse.SplitResultBytes.count'. Check your autosummary_generate setting. | ||
WARNING: autosummary: stub file not found 'urllib.parse.SplitResultBytes.index'. Check your autosummary_generate setting. | ||
ERROR: Unexpected indentation. |