@@ -65,25 +65,47 @@ def test_raises_invalid_with_count(self):
6565 with pytest .raises (
6666 AssertionError ,
6767 match = (
68- "Rule 'force-title': test_invalid_1 :"
68+ "Rule 'force-title': test_invalid_0 :"
6969 " expected one problem, but got no problems."
7070 ),
7171 ):
7272 tester .run (
7373 "force-title" ,
7474 ForceTitle ,
7575 invalid = [
76- RuleTest (dataset = INVALID_DATASET_1 , expected = 1 ),
7776 RuleTest (dataset = VALID_DATASET_1 , expected = 1 ),
7877 ],
7978 )
8079
81- def test_raises_invalid_with_message (self ):
80+ def test_raises_valid_with_count (self ):
8281 tester = RuleTester (rules = {"testing/force-title" : "error" })
8382 with pytest .raises (
8483 AssertionError ,
8584 match = (
86- "Rule 'force-title': test_invalid_1:"
85+ "Rule 'force-title':"
86+ " test_invalid_raises_valid_with_count:"
87+ " expected one problem, but got no problems."
88+ ),
89+ ):
90+ tester .run (
91+ "force-title" ,
92+ ForceTitle ,
93+ invalid = [
94+ RuleTest (
95+ dataset = VALID_DATASET_1 ,
96+ expected = 1 ,
97+ name = "raises_valid_with_count" ,
98+ ),
99+ ],
100+ )
101+
102+ def test_raises_invalid_with_matching_message (self ):
103+ tester = RuleTester (rules = {"testing/force-title" : "error" })
104+ with pytest .raises (
105+ AssertionError ,
106+ match = (
107+ "Rule 'force-title':"
108+ " test_invalid_raises_invalid_with_matching_message:"
87109 " expected one problem, but got no problems:\n "
88110 "Expected message:\n "
89111 " 0: Datasets must have a title"
@@ -94,11 +116,34 @@ def test_raises_invalid_with_message(self):
94116 ForceTitle ,
95117 invalid = [
96118 RuleTest (
97- dataset = INVALID_DATASET_1 ,
119+ dataset = VALID_DATASET_1 ,
98120 expected = ["Datasets must have a title" ],
121+ name = "raises_invalid_with_matching_message" ,
99122 ),
123+ ],
124+ )
125+
126+ def test_raises_invalid_with_mismatching_message (self ):
127+ tester = RuleTester (rules = {"testing/force-title" : "error" })
128+ with pytest .raises (
129+ AssertionError ,
130+ match = (
131+ "Rule 'force-title':"
132+ " test_invalid_raises_invalid_with_mismatching_message:"
133+ " got one error as expected, but encountered message mismatch:\n "
134+ "Message 0:\n "
135+ " Expected: Batasets bust bave a bitle\n "
136+ " Actual: Datasets must have a title"
137+ ),
138+ ):
139+ tester .run (
140+ "force-title" ,
141+ ForceTitle ,
142+ invalid = [
100143 RuleTest (
101- dataset = VALID_DATASET_1 , expected = ["Datasets must have a title" ]
144+ dataset = INVALID_DATASET_1 ,
145+ expected = ["Batasets bust bave a bitle" ],
146+ name = "raises_invalid_with_mismatching_message" ,
102147 ),
103148 ],
104149 )
0 commit comments