@@ -482,6 +482,39 @@ def test_use_ansi_enabled_extension(self):
482482 '\x1b [31mspam\x1b [0m'
483483 )
484484
485+ @with_content ("""\
486+ .. program-output:: echo spam
487+ :class: myclass""" )
488+ def test_class (self ):
489+ literal = self .doctree .next_node (literal_block )
490+ self .assertTrue (literal )
491+ self .assertIn ('myclass' , literal .get ('classes' ))
492+ self .assert_output (self .doctree , 'spam' )
493+ self .assert_cache (self .app , 'echo spam' , 'spam' )
494+
495+ @with_content ("""\
496+ .. program-output:: echo spam
497+ :class: myclass anotherclass""" )
498+ def test_multiple_classes (self ):
499+ literal = self .doctree .next_node (literal_block )
500+ self .assertTrue (literal )
501+ classes = literal .get ('classes' )
502+ self .assertIn ('myclass' , classes )
503+ self .assertIn ('anotherclass' , classes )
504+ self .assert_output (self .doctree , 'spam' )
505+ self .assert_cache (self .app , 'echo spam' , 'spam' )
506+
507+ @with_content ("""\
508+ .. program-output:: echo spam
509+ :class: myclass
510+ :caption: mycaption""" )
511+ def test_class_with_caption (self ):
512+ container_node = self .doctree .next_node (container )
513+ self .assertTrue (container_node )
514+ self .assertIn ('myclass' , container_node .get ('classes' ))
515+ self .assert_output (self .doctree , 'spam' , caption = 'mycaption' )
516+ self .assert_cache (self .app , 'echo spam' , 'spam' )
517+
485518def test_suite ():
486519 return unittest .defaultTestLoader .loadTestsFromName (__name__ )
487520
0 commit comments