@@ -84,7 +84,7 @@ def url_for_path(path):
84
84
85
85
return urljoin (
86
86
REMOTES_BASE_URL ,
87
- str (path .relative_to (REMOTES_DIR )).replace ("\\ " , "/" ) # Windows...
87
+ str (path .relative_to (REMOTES_DIR )).replace ("\\ " , "/" ), # Windows...
88
88
)
89
89
90
90
@@ -100,7 +100,8 @@ class SanityTests(unittest.TestCase):
100
100
print (f"Found { len (cls .test_files )} test files" )
101
101
102
102
cls .output_test_files = [
103
- each for each in collect (OUTPUT_ROOT_DIR )
103
+ each
104
+ for each in collect (OUTPUT_ROOT_DIR )
104
105
if each .name != "output-schema.json"
105
106
]
106
107
assert cls .output_test_files , "Didn't find the output test files!"
@@ -163,19 +164,21 @@ class SanityTests(unittest.TestCase):
163
164
self .assertLess (
164
165
len (case ["description" ]),
165
166
150 ,
166
- "Description is too long (keep it to less than 150 chars)."
167
+ "Description is too long (keep it to less than 150 chars)." ,
167
168
)
168
169
169
170
def test_all_test_descriptions_have_reasonable_length (self ):
170
171
"""
171
172
All tests have reasonably long descriptions.
172
173
"""
173
- for count , test in enumerate (tests (self .test_files + self .output_test_files )):
174
+ for count , test in enumerate (
175
+ tests (self .test_files + self .output_test_files )
176
+ ):
174
177
with self .subTest (description = test ["description" ]):
175
178
self .assertLess (
176
179
len (test ["description" ]),
177
180
70 ,
178
- "Description is too long (keep it to less than 70 chars)."
181
+ "Description is too long (keep it to less than 70 chars)." ,
179
182
)
180
183
print (f"Found { count } tests." )
181
184
@@ -191,7 +194,9 @@ class SanityTests(unittest.TestCase):
191
194
"""
192
195
All test cases have unique test descriptions in their tests.
193
196
"""
194
- for count , case in enumerate (cases (self .test_files + self .output_test_files )):
197
+ for count , case in enumerate (
198
+ cases (self .test_files + self .output_test_files )
199
+ ):
195
200
with self .subTest (description = case ["description" ]):
196
201
self .assertUnique (
197
202
test ["description" ] for test in case ["tests" ]
@@ -226,7 +231,7 @@ class SanityTests(unittest.TestCase):
226
231
Validator .check_schema (case ["schema" ])
227
232
except jsonschema .SchemaError :
228
233
self .fail (
229
- "Found an invalid schema."
234
+ "Found an invalid schema. "
230
235
"See the traceback for details on why."
231
236
)
232
237
else :
@@ -292,15 +297,21 @@ def main(arguments):
292
297
try :
293
298
import flask
294
299
except ImportError :
295
- print (textwrap .dedent ("""
300
+ print (
301
+ textwrap .dedent (
302
+ """
296
303
The Flask library is required to serve the remote schemas.
297
304
298
305
You can install it by running `pip install Flask`.
299
306
300
307
Alternatively, see the `jsonschema_suite remotes` or
301
308
`jsonschema_suite dump_remotes` commands to create static files
302
309
that can be served with your own web server.
303
- """ .strip ("\n " )))
310
+ """ .strip (
311
+ "\n "
312
+ )
313
+ )
314
+ )
304
315
sys .exit (1 )
305
316
306
317
app = flask .Flask (__name__ )
@@ -324,25 +335,27 @@ check = subparsers.add_parser("check", help="Sanity check the test suite.")
324
335
325
336
flatten = subparsers .add_parser (
326
337
"flatten" ,
327
- help = "Output a flattened file containing a selected version's test cases."
338
+ help = "Output a flattened file containing a selected version's test cases." ,
328
339
)
329
340
flatten .add_argument (
330
341
"--randomize" ,
331
342
action = "store_true" ,
332
343
help = "Randomize the order of the outputted cases." ,
333
344
)
334
345
flatten .add_argument (
335
- "version" , help = "The directory containing the version to output" ,
346
+ "version" ,
347
+ help = "The directory containing the version to output" ,
336
348
)
337
349
338
350
remotes = subparsers .add_parser (
339
351
"remotes" ,
340
352
help = "Output the expected URLs and their associated schemas for remote "
341
- "ref tests as a JSON object."
353
+ "ref tests as a JSON object." ,
342
354
)
343
355
344
356
dump_remotes = subparsers .add_parser (
345
- "dump_remotes" , help = "Dump the remote ref schemas into a file tree" ,
357
+ "dump_remotes" ,
358
+ help = "Dump the remote ref schemas into a file tree" ,
346
359
)
347
360
dump_remotes .add_argument (
348
361
"--update" ,
@@ -358,7 +371,7 @@ dump_remotes.add_argument(
358
371
359
372
serve = subparsers .add_parser (
360
373
"serve" ,
361
- help = "Start a webserver to serve schemas used by remote ref tests."
374
+ help = "Start a webserver to serve schemas used by remote ref tests." ,
362
375
)
363
376
364
377
if __name__ == "__main__" :
0 commit comments