@@ -633,6 +633,90 @@ def test_keyword_settings_too_many_times(self):
633
633
assert_tokens (data , expected , data_only = True )
634
634
635
635
636
+ class TestSectionHeaders (unittest .TestCase ):
637
+
638
+ def test_headers_allowed_everywhere (self ):
639
+ data = '''\
640
+ *** Settings ***
641
+ *** Setting ***
642
+ ***variables***
643
+ *VARIABLE* ARGS ARGH
644
+ *Keywords *** ...
645
+ ... ***
646
+ *** Keyword *** # Comment
647
+ *** Comments ***
648
+ *** Comment *** 1 2
649
+ ... 3 4
650
+ ... 5
651
+ '''
652
+ expected = [
653
+ (T .SETTING_HEADER , '*** Settings ***' , 1 , 0 ),
654
+ (T .EOS , '' , 1 , 16 ),
655
+ (T .SETTING_HEADER , '*** Setting ***' , 2 , 0 ),
656
+ (T .EOS , '' , 2 , 15 ),
657
+ (T .VARIABLE_HEADER , '***variables***' , 3 , 0 ),
658
+ (T .EOS , '' , 3 , 15 ),
659
+ (T .VARIABLE_HEADER , '*VARIABLE*' , 4 , 0 ),
660
+ (T .VARIABLE_HEADER , 'ARGS' , 4 , 14 ),
661
+ (T .VARIABLE_HEADER , 'ARGH' , 4 , 22 ),
662
+ (T .EOS , '' , 4 , 26 ),
663
+ (T .KEYWORD_HEADER , '*Keywords' , 5 , 0 ),
664
+ (T .KEYWORD_HEADER , '***' , 5 , 14 ),
665
+ (T .KEYWORD_HEADER , '...' , 5 , 21 ),
666
+ (T .KEYWORD_HEADER , '***' , 6 , 14 ),
667
+ (T .EOS , '' , 6 , 17 ),
668
+ (T .KEYWORD_HEADER , '*** Keyword ***' , 7 , 0 ),
669
+ (T .EOS , '' , 7 , 15 )
670
+ ]
671
+ assert_tokens (data , expected , get_tokens , data_only = True )
672
+ assert_tokens (data , expected , get_init_tokens , data_only = True )
673
+ assert_tokens (data , expected , get_resource_tokens , data_only = True )
674
+
675
+ def test_test_case_section (self ):
676
+ assert_tokens ('*** Test Cases ***' , [
677
+ (T .TESTCASE_HEADER , '*** Test Cases ***' , 1 , 0 ),
678
+ (T .EOS , '' , 1 , 18 ),
679
+ ], data_only = True )
680
+
681
+ def test_case_section_causes_error_in_init_file (self ):
682
+ assert_tokens ('*** Test Cases ***' , [
683
+ (T .ERROR , '*** Test Cases ***' , 1 , 0 ,
684
+ "'Test Cases' section is not allowed in suite initialization file." ),
685
+ (T .EOS , '' , 1 , 18 ),
686
+ ], get_init_tokens , data_only = True )
687
+
688
+ def test_case_section_causes_fatal_error_in_resource_file (self ):
689
+ assert_tokens ('*** Test Cases ***' , [
690
+ (T .FATAL_ERROR , '*** Test Cases ***' , 1 , 0 ,
691
+ "Resource file with 'Test Cases' section is invalid." ),
692
+ (T .EOS , '' , 1 , 18 ),
693
+ ], get_resource_tokens , data_only = True )
694
+
695
+ def test_invalid_section_in_test_case_file (self ):
696
+ assert_tokens ('*** Invalid ***' , [
697
+ (T .ERROR , '*** Invalid ***' , 1 , 0 ,
698
+ "Unrecognized section header '*** Invalid ***'. Valid sections: "
699
+ "'Settings', 'Variables', 'Test Cases', 'Tasks', 'Keywords' and 'Comments'." ),
700
+ (T .EOS , '' , 1 , 15 ),
701
+ ], data_only = True )
702
+
703
+ def test_invalid_section_in_init_file (self ):
704
+ assert_tokens ('*** S e t t i n g s ***' , [
705
+ (T .ERROR , '*** S e t t i n g s ***' , 1 , 0 ,
706
+ "Unrecognized section header '*** S e t t i n g s ***'. Valid sections: "
707
+ "'Settings', 'Variables', 'Keywords' and 'Comments'." ),
708
+ (T .EOS , '' , 1 , 23 ),
709
+ ], get_init_tokens , data_only = True )
710
+
711
+ def test_invalid_section_in_resource_file (self ):
712
+ assert_tokens ('*' , [
713
+ (T .ERROR , '*' , 1 , 0 ,
714
+ "Unrecognized section header '*'. Valid sections: "
715
+ "'Settings', 'Variables', 'Keywords' and 'Comments'." ),
716
+ (T .EOS , '' , 1 , 1 ),
717
+ ], get_resource_tokens , data_only = True )
718
+
719
+
636
720
class TestName (unittest .TestCase ):
637
721
638
722
def test_name_on_own_row (self ):
0 commit comments