Skip to content

Commit 48cc545

Browse files
committed
Merge branch 'patch-1'
* patch-1: Workaround for tests in Python 3.4 Fix Python detection for Python 3.x Python 3.4 for travis
2 parents f2d83f9 + be5097d commit 48cc545

File tree

3 files changed

+26
-20
lines changed

3 files changed

+26
-20
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ python:
44
- "2.6"
55
- "2.7"
66
- "3.3"
7+
- "3.4"
78
install:
89
- python setup.py -q install
910
script:
10-
- if [[ "$(python -c 'import sys; print sys.version_info[:2]')" == "(2, 6)" ]]; then pip install unittest2; fi
11+
- if [[ "$(python -c 'import sys; print(sys.version_info[:2])')" == "(2, 6)" ]]; then pip install unittest2; fi
1112
- py.test --tb=native jsonschema
1213
- python -m doctest README.rst

jsonschema/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ def _json_file(path):
4040
"-V", "--validator",
4141
type=_namedAnyWithDefault,
4242
help="the fully qualified object name of a validator to use, or, for "
43-
"validators that are registered with jsonschema, simply the name "
44-
"of the class.",
43+
"validators that are registered with jsonschema, simply the name "
44+
"of the class.",
4545
)
4646
parser.add_argument(
4747
"schema",

jsonschema/tests/test_cli.py

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,19 @@ def iter_errors(self, instance):
1818

1919

2020
class TestParser(unittest.TestCase):
21-
2221
FakeValidator = fake_validator()
2322

2423
def setUp(self):
25-
self.open = mock.mock_open(read_data='{}')
26-
patch = mock.patch.object(cli, "open", self.open, create=True)
27-
patch.start()
28-
self.addCleanup(patch.stop)
24+
mock_open = mock.mock_open()
25+
patch_open = mock.patch.object(cli, "open", mock_open, create=True)
26+
patch_open.start()
27+
self.addCleanup(patch_open.stop)
28+
29+
mock_json_load = mock.Mock()
30+
mock_json_load.return_value = {}
31+
patch_json_load = mock.patch("json.load")
32+
patch_json_load.start()
33+
self.addCleanup(patch_json_load.stop)
2934

3035
def test_find_validator_by_fully_qualified_object_name(self):
3136
arguments = cli.parse_args(
@@ -54,10 +59,10 @@ def test_successful_validation(self):
5459
stdout, stderr = StringIO(), StringIO()
5560
exit_code = cli.run(
5661
{
57-
"validator" : fake_validator(),
58-
"schema" : {},
59-
"instances" : [1],
60-
"error_format" : "{error.message}",
62+
"validator": fake_validator(),
63+
"schema": {},
64+
"instances": [1],
65+
"error_format": "{error.message}",
6166
},
6267
stdout=stdout,
6368
stderr=stderr,
@@ -71,10 +76,10 @@ def test_unsuccessful_validation(self):
7176
stdout, stderr = StringIO(), StringIO()
7277
exit_code = cli.run(
7378
{
74-
"validator" : fake_validator([error]),
75-
"schema" : {},
76-
"instances" : [1],
77-
"error_format" : "{error.instance} - {error.message}",
79+
"validator": fake_validator([error]),
80+
"schema": {},
81+
"instances": [1],
82+
"error_format": "{error.instance} - {error.message}",
7883
},
7984
stdout=stdout,
8085
stderr=stderr,
@@ -92,10 +97,10 @@ def test_unsuccessful_validation_multiple_instances(self):
9297
stdout, stderr = StringIO(), StringIO()
9398
exit_code = cli.run(
9499
{
95-
"validator" : fake_validator(first_errors, second_errors),
96-
"schema" : {},
97-
"instances" : [1, 2],
98-
"error_format" : "{error.instance} - {error.message}\t",
100+
"validator": fake_validator(first_errors, second_errors),
101+
"schema": {},
102+
"instances": [1, 2],
103+
"error_format": "{error.instance} - {error.message}\t",
99104
},
100105
stdout=stdout,
101106
stderr=stderr,

0 commit comments

Comments
 (0)