|
1 | 1 | #! /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 | + |
3 | 18 | import errno
|
4 | 19 | import fnmatch
|
5 | 20 | import json
|
6 | 21 | import os
|
7 | 22 | import random
|
8 | 23 | import shutil
|
9 |
| -import sys |
10 | 24 | import unittest
|
11 | 25 | import warnings
|
12 | 26 |
|
| 27 | +if getattr(unittest, "skipIf", None) is None: |
| 28 | + unittest.skipIf = lambda cond, msg : lambda fn : fn |
| 29 | + |
13 | 30 | try:
|
14 | 31 | import jsonschema
|
15 | 32 | except ImportError:
|
@@ -109,7 +126,7 @@ class SanityTests(unittest.TestCase):
|
109 | 126 |
|
110 | 127 | def test_all_descriptions_are_unique(self):
|
111 | 128 | 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"]) |
113 | 130 | self.assertEqual(
|
114 | 131 | len(descriptions),
|
115 | 132 | len(group["tests"]),
|
@@ -188,7 +205,15 @@ def main(arguments):
|
188 | 205 | try:
|
189 | 206 | from flask import Flask, jsonify
|
190 | 207 | 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")) |
192 | 217 | sys.exit(1)
|
193 | 218 |
|
194 | 219 | app = Flask(__name__)
|
|
0 commit comments