@@ -311,3 +311,77 @@ def test_check_enum_for_list_failed(logger):
311311 config .init_values ()
312312 check_confval_types (None , config )
313313 assert logger .warning .called
314+
315+
316+ nitpick_warnings = [
317+ "WARNING: py:const reference target not found: prefix.anything.postfix" ,
318+ "WARNING: py:class reference target not found: prefix.anything" ,
319+ "WARNING: py:class reference target not found: anything.postfix" ,
320+ "WARNING: js:class reference target not found: prefix.anything.postfix" ,
321+ ]
322+
323+
324+ @pytest .mark .sphinx (testroot = 'nitpicky-warnings' )
325+ def test_nitpick_base (app , status , warning ):
326+ app .builder .build_all ()
327+
328+ warning = warning .getvalue ().strip ().split ('\n ' )
329+ assert len (warning ) == len (nitpick_warnings )
330+ for actual , expected in zip (warning , nitpick_warnings ):
331+ assert expected in actual
332+
333+
334+ @pytest .mark .sphinx (testroot = 'nitpicky-warnings' , confoverrides = {
335+ 'nitpick_ignore' : [
336+ ('py:const' , 'prefix.anything.postfix' ),
337+ ('py:class' , 'prefix.anything' ),
338+ ('py:class' , 'anything.postfix' ),
339+ ('js:class' , 'prefix.anything.postfix' ),
340+ ],
341+ })
342+ def test_nitpick_ignore (app , status , warning ):
343+ app .builder .build_all ()
344+ assert not len (warning .getvalue ().strip ())
345+
346+
347+ @pytest .mark .sphinx (testroot = 'nitpicky-warnings' , confoverrides = {
348+ 'nitpick_ignore_regex' : [
349+ (r'py:.*' , r'.*postfix' ),
350+ (r'.*:class' , r'prefix.*' ),
351+ ]
352+ })
353+ def test_nitpick_ignore_regex1 (app , status , warning ):
354+ app .builder .build_all ()
355+ assert not len (warning .getvalue ().strip ())
356+
357+
358+ @pytest .mark .sphinx (testroot = 'nitpicky-warnings' , confoverrides = {
359+ 'nitpick_ignore_regex' : [
360+ (r'py:.*' , r'prefix.*' ),
361+ (r'.*:class' , r'.*postfix' ),
362+ ]
363+ })
364+ def test_nitpick_ignore_regex2 (app , status , warning ):
365+ app .builder .build_all ()
366+ assert not len (warning .getvalue ().strip ())
367+
368+
369+ @pytest .mark .sphinx (testroot = 'nitpicky-warnings' , confoverrides = {
370+ 'nitpick_ignore_regex' : [
371+ # None of these should match
372+ (r'py:' , r'.*' ),
373+ (r':class' , r'.*' ),
374+ (r'' , r'.*' ),
375+ (r'.*' , r'anything' ),
376+ (r'.*' , r'prefix' ),
377+ (r'.*' , r'postfix' ),
378+ (r'.*' , r'' ),
379+ ]
380+ })
381+ def test_nitpick_ignore_regex_fullmatch (app , status , warning ):
382+ app .builder .build_all ()
383+
384+ warning = warning .getvalue ().strip ().split ('\n ' )
385+ assert len (warning ) == len (nitpick_warnings )
386+ for actual , expected in zip (warning , nitpick_warnings ):
387+ assert expected in actual
0 commit comments