Skip to content

Commit 59dadec

Browse files
committed
Verbose errors.
1 parent 073d6ed commit 59dadec

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

bin/jsonschema_suite

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,32 @@
11
#! /usr/bin/env python
2-
import argparse
2+
import sys
3+
import textwrap
4+
5+
try:
6+
import argparse
7+
except ImportError:
8+
print textwrap.dedent("""
9+
The argparse library could not be imported. jsonschema_suite requires
10+
either Python 2.7 or for you to install argparse. You can do so by
11+
running `pip install argparse`, `easy_install argparse` or by
12+
downloading argparse and running `python2.6 setup.py install`.
13+
14+
See https://pypi.python.org/pypi/argparse for details.
15+
""".strip("\n"))
16+
sys.exit(1)
17+
318
import errno
419
import fnmatch
520
import json
621
import os
722
import random
823
import shutil
9-
import sys
1024
import unittest
1125
import warnings
1226

27+
if getattr(unittest, "skipIf", None) is None:
28+
unittest.skipIf = lambda cond, msg : lambda fn : fn
29+
1330
try:
1431
import jsonschema
1532
except ImportError:
@@ -109,7 +126,7 @@ class SanityTests(unittest.TestCase):
109126

110127
def test_all_descriptions_are_unique(self):
111128
for group in groups(self.test_files):
112-
descriptions = {test["description"] for test in group["tests"]}
129+
descriptions = set(test["description"] for test in group["tests"])
113130
self.assertEqual(
114131
len(descriptions),
115132
len(group["tests"]),
@@ -188,7 +205,15 @@ def main(arguments):
188205
try:
189206
from flask import Flask, jsonify
190207
except ImportError:
191-
print "Flask is required to serve the test schemas. Aborting."
208+
print textwrap.dedent("""
209+
The Flask library is required to serve the remote schemas.
210+
211+
You can install it by running `pip install Flask`.
212+
213+
Alternatively, see the `jsonschema_suite remotes` or
214+
`jsonschema_suite dump_remotes` commands to create static files
215+
that can be served with your own web server.
216+
""".strip("\n"))
192217
sys.exit(1)
193218

194219
app = Flask(__name__)

0 commit comments

Comments
 (0)