Skip to content

Commit e7d2975

Browse files
committed
Whitespacin'.
1 parent 2658dd6 commit e7d2975

5 files changed

Lines changed: 182 additions & 182 deletions

File tree

jsonschema/tests/test_exceptions.py

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ def best_match(self, errors):
2121
def test_shallower_errors_are_better_matches(self):
2222
validator = Draft4Validator(
2323
{
24-
"properties" : {
25-
"foo" : {
26-
"minProperties" : 2,
27-
"properties" : {"bar" : {"type" : "object"}},
24+
"properties": {
25+
"foo": {
26+
"minProperties": 2,
27+
"properties": {"bar": {"type": "object"}},
2828
},
2929
},
3030
},
3131
)
32-
best = self.best_match(validator.iter_errors({"foo" : {"bar" : []}}))
32+
best = self.best_match(validator.iter_errors({"foo": {"bar": []}}))
3333
self.assertEqual(best.validator, "minProperties")
3434

3535
def test_oneOf_and_anyOf_are_weak_matches(self):
@@ -41,9 +41,9 @@ def test_oneOf_and_anyOf_are_weak_matches(self):
4141

4242
validator = Draft4Validator(
4343
{
44-
"minProperties" : 2,
45-
"anyOf" : [{"type" : "string"}, {"type" : "number"}],
46-
"oneOf" : [{"type" : "string"}, {"type" : "number"}],
44+
"minProperties": 2,
45+
"anyOf": [{"type": "string"}, {"type": "number"}],
46+
"oneOf": [{"type": "string"}, {"type": "number"}],
4747
}
4848
)
4949
best = self.best_match(validator.iter_errors({}))
@@ -62,17 +62,17 @@ def test_if_the_most_relevant_error_is_anyOf_it_is_traversed(self):
6262

6363
validator = Draft4Validator(
6464
{
65-
"properties" : {
66-
"foo" : {
67-
"anyOf" : [
68-
{"type" : "string"},
69-
{"properties" : {"bar" : {"type" : "array"}}},
65+
"properties": {
66+
"foo": {
67+
"anyOf": [
68+
{"type": "string"},
69+
{"properties": {"bar": {"type": "array"}}},
7070
],
7171
},
7272
},
7373
},
7474
)
75-
best = self.best_match(validator.iter_errors({"foo" : {"bar" : 12}}))
75+
best = self.best_match(validator.iter_errors({"foo": {"bar": 12}}))
7676
self.assertEqual(best.validator_value, "array")
7777

7878
def test_if_the_most_relevant_error_is_oneOf_it_is_traversed(self):
@@ -88,17 +88,17 @@ def test_if_the_most_relevant_error_is_oneOf_it_is_traversed(self):
8888

8989
validator = Draft4Validator(
9090
{
91-
"properties" : {
92-
"foo" : {
93-
"oneOf" : [
94-
{"type" : "string"},
95-
{"properties" : {"bar" : {"type" : "array"}}},
91+
"properties": {
92+
"foo": {
93+
"oneOf": [
94+
{"type": "string"},
95+
{"properties": {"bar": {"type": "array"}}},
9696
],
9797
},
9898
},
9999
},
100100
)
101-
best = self.best_match(validator.iter_errors({"foo" : {"bar" : 12}}))
101+
best = self.best_match(validator.iter_errors({"foo": {"bar": 12}}))
102102
self.assertEqual(best.validator_value, "array")
103103

104104
def test_if_the_most_relevant_error_is_allOf_it_is_traversed(self):
@@ -110,32 +110,32 @@ def test_if_the_most_relevant_error_is_allOf_it_is_traversed(self):
110110

111111
validator = Draft4Validator(
112112
{
113-
"properties" : {
114-
"foo" : {
115-
"allOf" : [
116-
{"type" : "string"},
117-
{"properties" : {"bar" : {"type" : "array"}}},
113+
"properties": {
114+
"foo": {
115+
"allOf": [
116+
{"type": "string"},
117+
{"properties": {"bar": {"type": "array"}}},
118118
],
119119
},
120120
},
121121
},
122122
)
123-
best = self.best_match(validator.iter_errors({"foo" : {"bar" : 12}}))
123+
best = self.best_match(validator.iter_errors({"foo": {"bar": 12}}))
124124
self.assertEqual(best.validator_value, "string")
125125

126126
def test_nested_context_for_oneOf(self):
127127
validator = Draft4Validator(
128128
{
129-
"properties" : {
130-
"foo" : {
131-
"oneOf" : [
132-
{"type" : "string"},
129+
"properties": {
130+
"foo": {
131+
"oneOf": [
132+
{"type": "string"},
133133
{
134-
"oneOf" : [
135-
{"type" : "string"},
134+
"oneOf": [
135+
{"type": "string"},
136136
{
137-
"properties" : {
138-
"bar" : {"type" : "array"},
137+
"properties": {
138+
"bar": {"type": "array"},
139139
},
140140
},
141141
],
@@ -145,11 +145,11 @@ def test_nested_context_for_oneOf(self):
145145
},
146146
},
147147
)
148-
best = self.best_match(validator.iter_errors({"foo" : {"bar" : 12}}))
148+
best = self.best_match(validator.iter_errors({"foo": {"bar": 12}}))
149149
self.assertEqual(best.validator_value, "array")
150150

151151
def test_one_error(self):
152-
validator = Draft4Validator({"minProperties" : 2})
152+
validator = Draft4Validator({"minProperties": 2})
153153
error, = validator.iter_errors({})
154154
self.assertEqual(
155155
exceptions.best_match(validator.iter_errors({})).validator,
@@ -232,7 +232,7 @@ def test_it_does_not_contain_an_item_if_the_item_had_no_error(self):
232232
def test_validators_that_failed_appear_in_errors_dict(self):
233233
error = exceptions.ValidationError("a message", validator="foo")
234234
tree = exceptions.ErrorTree([error])
235-
self.assertEqual(tree.errors, {"foo" : error})
235+
self.assertEqual(tree.errors, {"foo": error})
236236

237237
def test_it_creates_a_child_tree_for_each_nested_path(self):
238238
errors = [
@@ -249,7 +249,7 @@ def test_children_have_their_errors_dicts_built(self):
249249
exceptions.ValidationError("2", validator="quux", path=["bar", 0]),
250250
)
251251
tree = exceptions.ErrorTree([e1, e2])
252-
self.assertEqual(tree["bar"][0].errors, {"foo" : e1, "quux" : e2})
252+
self.assertEqual(tree["bar"][0].errors, {"foo": e1, "quux": e2})
253253

254254
def test_regression_multiple_errors_with_instance(self):
255255
e1, e2 = (

jsonschema/tests/test_format.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_it_raises_a_key_error_for_unknown_formats(self):
2424
def test_it_can_register_cls_checkers(self):
2525
with mock.patch.dict(FormatChecker.checkers, clear=True):
2626
FormatChecker.cls_checks("new")(self.fn)
27-
self.assertEqual(FormatChecker.checkers, {"new" : (self.fn, ())})
27+
self.assertEqual(FormatChecker.checkers, {"new": (self.fn, ())})
2828

2929
def test_it_can_register_checkers(self):
3030
checker = FormatChecker()
@@ -55,7 +55,7 @@ def test_format_error_causes_become_validation_error_causes(self):
5555
checker = FormatChecker()
5656
checker.checks("foo", raises=ValueError)(self.fn)
5757
cause = self.fn.side_effect = ValueError()
58-
validator = Draft4Validator({"format" : "foo"}, format_checker=checker)
58+
validator = Draft4Validator({"format": "foo"}, format_checker=checker)
5959

6060
with self.assertRaises(ValidationError) as cm:
6161
validator.validate("bar")

jsonschema/tests/test_jsonschema_test_suite.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,14 @@ def add_test_methods(test_class):
122122
class TypesMixin(object):
123123
@unittest.skipIf(PY3, "In Python 3 json.load always produces unicode")
124124
def test_string_a_bytestring_is_a_string(self):
125-
self.validator_class({"type" : "string"}).validate(b"foo")
125+
self.validator_class({"type": "string"}).validate(b"foo")
126126

127127

128128
class DecimalMixin(object):
129129
def test_it_can_validate_with_decimals(self):
130-
schema = {"type" : "number"}
130+
schema = {"type": "number"}
131131
validator = self.validator_class(
132-
schema, types={"number" : (int, float, Decimal)}
132+
schema, types={"number": (int, float, Decimal)}
133133
)
134134

135135
for valid in [1, 1.1, Decimal(1) / Decimal(8)]:
@@ -158,7 +158,7 @@ def missing_format(case, test):
158158
class FormatMixin(object):
159159
def test_it_returns_true_for_formats_it_does_not_know_about(self):
160160
validator = self.validator_class(
161-
{"format" : "carrot"}, format_checker=FormatChecker(),
161+
{"format": "carrot"}, format_checker=FormatChecker(),
162162
)
163163
validator.validate("bugs")
164164

@@ -169,7 +169,7 @@ def test_it_does_not_validate_formats_by_default(self):
169169
def test_it_validates_formats_if_a_checker_is_provided(self):
170170
checker = mock.Mock(spec=FormatChecker)
171171
validator = self.validator_class(
172-
{"format" : "foo"}, format_checker=checker,
172+
{"format": "foo"}, format_checker=checker,
173173
)
174174

175175
validator.validate("bar")
@@ -187,7 +187,7 @@ def test_it_validates_formats_if_a_checker_is_provided(self):
187187
def test_it_validates_formats_of_any_type(self):
188188
checker = mock.Mock(spec=FormatChecker)
189189
validator = self.validator_class(
190-
{"format" : "foo"}, format_checker=checker,
190+
{"format": "foo"}, format_checker=checker,
191191
)
192192

193193
validator.validate([1, 2, 3])
@@ -224,10 +224,10 @@ def narrow_unicode_build(case, test): # This isn't, skip nothing.
224224
@load_json_cases("draft3/optional/zeroTerminatedFloats.json")
225225
class TestDraft3(unittest.TestCase, TypesMixin, DecimalMixin, FormatMixin):
226226
validator_class = Draft3Validator
227-
validator_kwargs = {"format_checker" : draft3_format_checker}
227+
validator_kwargs = {"format_checker": draft3_format_checker}
228228

229229
def test_any_type_is_valid_for_type_any(self):
230-
validator = self.validator_class({"type" : "any"})
230+
validator = self.validator_class({"type": "any"})
231231
validator.validate(mock.Mock())
232232

233233
# TODO: we're in need of more meta schema tests
@@ -239,7 +239,7 @@ def test_invalid_properties(self):
239239
def test_minItems_invalid_string(self):
240240
with self.assertRaises(SchemaError):
241241
# needs to be an integer
242-
validate([1], {"minItems" : "1"}, cls=self.validator_class)
242+
validate([1], {"minItems": "1"}, cls=self.validator_class)
243243

244244

245245
@load_json_cases(
@@ -254,7 +254,7 @@ def test_minItems_invalid_string(self):
254254
@load_json_cases("draft4/optional/zeroTerminatedFloats.json")
255255
class TestDraft4(unittest.TestCase, TypesMixin, DecimalMixin, FormatMixin):
256256
validator_class = Draft4Validator
257-
validator_kwargs = {"format_checker" : draft4_format_checker}
257+
validator_kwargs = {"format_checker": draft4_format_checker}
258258

259259
# TODO: we're in need of more meta schema tests
260260
def test_invalid_properties(self):
@@ -265,7 +265,7 @@ def test_invalid_properties(self):
265265
def test_minItems_invalid_string(self):
266266
with self.assertRaises(SchemaError):
267267
# needs to be an integer
268-
validate([1], {"minItems" : "1"}, cls=self.validator_class)
268+
validate([1], {"minItems": "1"}, cls=self.validator_class)
269269

270270

271271
class RemoteRefResolutionMixin(object):
@@ -277,7 +277,7 @@ def setUp(self):
277277

278278
def resolve(self, reference):
279279
_, _, reference = reference.partition("http://localhost:1234/")
280-
return mock.Mock(**{"json.return_value" : REMOTES.get(reference)})
280+
return mock.Mock(**{"json.return_value": REMOTES.get(reference)})
281281

282282

283283
@load_json_cases("draft3/refRemote.json")

0 commit comments

Comments
 (0)