Skip to content

Commit 83f8e7f

Browse files
committed
Merge branch 'py3' of github.com:gazpachoking/JSON-Schema-Test-Suite into develop
2 parents 29e2c7c + 8b2869d commit 83f8e7f

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

bin/jsonschema_suite

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
#! /usr/bin/env python
2+
from __future__ import print_function
23
import sys
34
import textwrap
45

56
try:
67
import argparse
78
except ImportError:
8-
print textwrap.dedent("""
9+
print(textwrap.dedent("""
910
The argparse library could not be imported. jsonschema_suite requires
1011
either Python 2.7 or for you to install argparse. You can do so by
1112
running `pip install argparse`, `easy_install argparse` or by
1213
downloading argparse and running `python2.6 setup.py install`.
1314
1415
See https://pypi.python.org/pypi/argparse for details.
15-
""".strip("\n"))
16+
""".strip("\n")))
1617
sys.exit(1)
1718

1819
import errno
@@ -33,7 +34,8 @@ except ImportError:
3334
jsonschema = None
3435

3536

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__")
3739
SUITE_ROOT_DIR = os.path.join(ROOT_DIR, "tests")
3840

3941
REMOTES = {
@@ -102,9 +104,9 @@ def collect(root_dir):
102104
class SanityTests(unittest.TestCase):
103105
@classmethod
104106
def setUpClass(cls):
105-
print "Looking for tests in %s" % SUITE_ROOT_DIR
107+
print("Looking for tests in %s" % SUITE_ROOT_DIR)
106108
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))
108110
assert cls.test_files, "Didn't find the test files!"
109111

110112
def test_all_files_are_valid_json(self):
@@ -158,7 +160,7 @@ class SanityTests(unittest.TestCase):
158160
self.fail(str(error))
159161

160162
def test_remote_schemas_are_updated(self):
161-
for url, schema in REMOTES.iteritems():
163+
for url, schema in REMOTES.items():
162164
filepath = os.path.join(REMOTES_DIR, url)
163165
with open(filepath) as schema_file:
164166
self.assertEqual(json.load(schema_file), schema)
@@ -186,11 +188,11 @@ def main(arguments):
186188
os.makedirs(arguments.out_dir)
187189
except OSError as e:
188190
if e.errno == errno.EEXIST:
189-
print "%s already exists. Aborting." % arguments.out_dir
191+
print("%s already exists. Aborting." % arguments.out_dir)
190192
sys.exit(1)
191193
raise
192194

193-
for url, schema in REMOTES.iteritems():
195+
for url, schema in REMOTES.items():
194196
filepath = os.path.join(arguments.out_dir, url)
195197

196198
try:
@@ -205,15 +207,15 @@ def main(arguments):
205207
try:
206208
from flask import Flask, jsonify
207209
except ImportError:
208-
print textwrap.dedent("""
210+
print(textwrap.dedent("""
209211
The Flask library is required to serve the remote schemas.
210212
211213
You can install it by running `pip install Flask`.
212214
213215
Alternatively, see the `jsonschema_suite remotes` or
214216
`jsonschema_suite dump_remotes` commands to create static files
215217
that can be served with your own web server.
216-
""".strip("\n"))
218+
""".strip("\n")))
217219
sys.exit(1)
218220

219221
app = Flask(__name__)

0 commit comments

Comments
 (0)