1
1
#! /usr/bin/env python
2
+ from __future__ import print_function
2
3
import sys
3
4
import textwrap
4
5
5
6
try :
6
7
import argparse
7
8
except ImportError :
8
- print textwrap .dedent ("""
9
+ print ( textwrap .dedent ("""
9
10
The argparse library could not be imported. jsonschema_suite requires
10
11
either Python 2.7 or for you to install argparse. You can do so by
11
12
running `pip install argparse`, `easy_install argparse` or by
12
13
downloading argparse and running `python2.6 setup.py install`.
13
14
14
15
See https://pypi.python.org/pypi/argparse for details.
15
- """ .strip ("\n " ))
16
+ """ .strip ("\n " )))
16
17
sys .exit (1 )
17
18
18
19
import errno
@@ -33,7 +34,8 @@ except ImportError:
33
34
jsonschema = None
34
35
35
36
36
- ROOT_DIR = os .path .join (os .path .dirname (__file__ ), os .pardir )
37
+ ROOT_DIR = os .path .join (
38
+ os .path .dirname (__file__ ), os .pardir ).rstrip ("__pycache__" )
37
39
SUITE_ROOT_DIR = os .path .join (ROOT_DIR , "tests" )
38
40
39
41
REMOTES = {
@@ -102,9 +104,9 @@ def collect(root_dir):
102
104
class SanityTests (unittest .TestCase ):
103
105
@classmethod
104
106
def setUpClass (cls ):
105
- print "Looking for tests in %s" % SUITE_ROOT_DIR
107
+ print ( "Looking for tests in %s" % SUITE_ROOT_DIR )
106
108
cls .test_files = list (collect (SUITE_ROOT_DIR ))
107
- print "Found %s test files" % len (cls .test_files )
109
+ print ( "Found %s test files" % len (cls .test_files ) )
108
110
assert cls .test_files , "Didn't find the test files!"
109
111
110
112
def test_all_files_are_valid_json (self ):
@@ -158,7 +160,7 @@ class SanityTests(unittest.TestCase):
158
160
self .fail (str (error ))
159
161
160
162
def test_remote_schemas_are_updated (self ):
161
- for url , schema in REMOTES .iteritems ():
163
+ for url , schema in REMOTES .items ():
162
164
filepath = os .path .join (REMOTES_DIR , url )
163
165
with open (filepath ) as schema_file :
164
166
self .assertEqual (json .load (schema_file ), schema )
@@ -186,11 +188,11 @@ def main(arguments):
186
188
os .makedirs (arguments .out_dir )
187
189
except OSError as e :
188
190
if e .errno == errno .EEXIST :
189
- print "%s already exists. Aborting." % arguments .out_dir
191
+ print ( "%s already exists. Aborting." % arguments .out_dir )
190
192
sys .exit (1 )
191
193
raise
192
194
193
- for url , schema in REMOTES .iteritems ():
195
+ for url , schema in REMOTES .items ():
194
196
filepath = os .path .join (arguments .out_dir , url )
195
197
196
198
try :
@@ -205,15 +207,15 @@ def main(arguments):
205
207
try :
206
208
from flask import Flask , jsonify
207
209
except ImportError :
208
- print textwrap .dedent ("""
210
+ print ( textwrap .dedent ("""
209
211
The Flask library is required to serve the remote schemas.
210
212
211
213
You can install it by running `pip install Flask`.
212
214
213
215
Alternatively, see the `jsonschema_suite remotes` or
214
216
`jsonschema_suite dump_remotes` commands to create static files
215
217
that can be served with your own web server.
216
- """ .strip ("\n " ))
218
+ """ .strip ("\n " )))
217
219
sys .exit (1 )
218
220
219
221
app = Flask (__name__ )
0 commit comments