@@ -23,6 +23,7 @@ def check_warnings(file: Path) -> bool:
23
23
0 if the warnings are all there
24
24
1 if some warning are not registered or unexpected
25
25
"""
26
+ windows = platform .system ().lower () == "windows"
26
27
# print some log
27
28
print ("\n === Sphinx Warnings test ===\n " )
28
29
@@ -32,26 +33,31 @@ def check_warnings(file: Path) -> bool:
32
33
33
34
test_warnings = file .read_text ().strip ().split ("\n " )
34
35
ref_warnings = warning_file .read_text ().strip ().split ("\n " )
35
- if platform . system (). lower () == " windows" :
36
+ if windows :
36
37
ref_warnings += extra_warning_file .read_text ().strip ().split ("\n " )
37
38
39
+ extra = f' and "{ extra_warning_file } "' if windows else ""
38
40
print (
39
41
f'Checking build warnings in file: "{ file } " and comparing to expected '
40
- f'warnings defined in "{ warning_file } "\n \n '
42
+ f'warnings defined in "{ warning_file } "{ extra } \n \n '
41
43
)
42
44
43
- for refw in ref_warnings [::- 1 ]:
45
+ for _rw in ref_warnings [::- 1 ]:
44
46
found = False
45
- for testw in test_warnings :
46
- if refw in testw :
47
- ref_warnings .remove (refw )
48
- test_warnings .remove (testw )
47
+ for _tw in test_warnings :
48
+ if _rw in _tw :
49
+ ref_warnings .remove (_rw )
50
+ test_warnings .remove (_tw )
49
51
found = True
50
52
break
51
53
if not found :
52
- print (f"{ Fore .YELLOW } Warning was not raised: { Fore .RESET } { refw } \n " )
53
- for testw in test_warnings :
54
- print (f"{ Fore .YELLOW } Unexpected warning: { Fore .RESET } { testw } \n " )
54
+ print (f"{ Fore .YELLOW } Warning was not raised: { Fore .RESET } { _rw } \n " )
55
+ # warn about unexpected warnings (unless they're the empty string)
56
+ for _tw in test_warnings [::- 1 ]:
57
+ if len (_tw ):
58
+ print (f"{ Fore .YELLOW } Unexpected warning: { Fore .RESET } { _tw } \n " )
59
+ else :
60
+ test_warnings .remove (_tw )
55
61
return len (test_warnings ) != 0 or len (ref_warnings ) != 0
56
62
57
63
0 commit comments