File tree Expand file tree Collapse file tree 4 files changed +32
-6
lines changed Expand file tree Collapse file tree 4 files changed +32
-6
lines changed Original file line number Diff line number Diff line change @@ -160,6 +160,32 @@ class SanityTests(unittest.TestCase):
160
160
)
161
161
print (f"Found { count } test cases." )
162
162
163
+ def test_descriptions_do_not_use_modal_verbs (self ):
164
+ """
165
+ Instead of saying "test that X frobs" or "X should frob" use "X frobs".
166
+
167
+ See e.g. https://jml.io/pages/test-docstrings.html
168
+
169
+ This test isn't comprehensive (it doesn't catch all the extra
170
+ verbiage there), but it's just to catch whatever it manages to
171
+ cover.
172
+ """
173
+
174
+ message = (
175
+ "In descriptions, don't say 'Test that X frobs' or 'X should "
176
+ "frob' or 'X should be valid'. Just say 'X frobs' or 'X is "
177
+ "valid'. It's shorter, and the test suite is entirely about "
178
+ "what *should* be already. "
179
+ "See https://jml.io/pages/test-docstrings.html for help."
180
+ )
181
+ for test in tests (self .test_files ):
182
+ with self .subTest (description = test ["description" ]):
183
+ self .assertNotRegex (
184
+ test ["description" ],
185
+ r"\bshould\b" ,
186
+ message ,
187
+ )
188
+
163
189
@unittest .skipIf (jsonschema is None , "Validation library not present!" )
164
190
def test_all_schemas_are_valid (self ):
165
191
"""
Original file line number Diff line number Diff line change 159
159
},
160
160
"tests" : [
161
161
{
162
- "description" : " $ref should resolve to /$defs/A/allOf/1" ,
162
+ "description" : " $ref resolves to /$defs/A/allOf/1" ,
163
163
"data" : " a" ,
164
164
"valid" : true
165
165
},
166
166
{
167
- "description" : " $ref should not resolve to /$defs/A/allOf/0" ,
167
+ "description" : " $ref does not resolve to /$defs/A/allOf/0" ,
168
168
"data" : 1 ,
169
169
"valid" : false
170
170
}
Original file line number Diff line number Diff line change 159
159
},
160
160
"tests" : [
161
161
{
162
- "description" : " $ref should resolve to /$defs/A/allOf/1" ,
162
+ "description" : " $ref resolves to /$defs/A/allOf/1" ,
163
163
"data" : " a" ,
164
164
"valid" : true
165
165
},
166
166
{
167
- "description" : " $ref should not resolve to /$defs/A/allOf/0" ,
167
+ "description" : " $ref does not resolve to /$defs/A/allOf/0" ,
168
168
"data" : 1 ,
169
169
"valid" : false
170
170
}
Original file line number Diff line number Diff line change 159
159
},
160
160
"tests" : [
161
161
{
162
- "description" : " $ref should resolve to /$defs/A/allOf/1" ,
162
+ "description" : " $ref resolves to /$defs/A/allOf/1" ,
163
163
"data" : " a" ,
164
164
"valid" : true
165
165
},
166
166
{
167
- "description" : " $ref should not resolve to /$defs/A/allOf/0" ,
167
+ "description" : " $ref does not resolve to /$defs/A/allOf/0" ,
168
168
"data" : 1 ,
169
169
"valid" : false
170
170
}
You can’t perform that action at this time.
0 commit comments