Merge lp:~zyga/linaro-python-json/1.1 into lp:linaro-python-json

Proposed by Zygmunt Krynicki
Status: Merged
Merged at revision: 113
Proposed branch: lp:~zyga/linaro-python-json/1.1
Merge into: lp:linaro-python-json
Diff against target: 70 lines (+21/-3)
3 files modified
linaro_json/__init__.py (+2/-2)
linaro_json/schema.py (+8/-1)
linaro_json/tests/test_schema.py (+11/-0)
To merge this branch: bzr merge lp:~zyga/linaro-python-json/1.1
Reviewer Review Type Date Requested Status
James Westby (community) Approve
Review via email: mp+42358@code.launchpad.net

Description of the change

This branch adds a small feature (support for schema default) and prepares for 1.1 release

To post a comment you must log in.
Revision history for this message
James Westby (james-w) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'linaro_json/__init__.py'
2--- linaro_json/__init__.py 2010-11-25 10:08:39 +0000
3+++ linaro_json/__init__.py 2010-12-01 13:32:52 +0000
4@@ -334,7 +334,7 @@
5 )
6
7
8-__version__ = (1, 0, 0, "final", 0)
9+__version__ = (1, 1, 0, "final", 0)
10
11
12 def get_version():
13@@ -342,7 +342,7 @@
14 Return a string representing the version of linaro_json package
15 """
16 major, minor, micro, releaselevel, serial = __version__
17- assert releaselevel in ('alpha', 'beta', 'candidate', 'final')
18+ assert releaselevel in ('dev', 'alpha', 'beta', 'candidate', 'final')
19 base_version = "%s.%s.%s" % (major, minor, micro)
20 if releaselevel != 'final':
21 base_version += "-%s" % releaselevel
22
23=== modified file 'linaro_json/schema.py'
24--- linaro_json/schema.py 2010-11-25 10:08:39 +0000
25+++ linaro_json/schema.py 2010-12-01 13:32:52 +0000
26@@ -20,7 +20,7 @@
27 JSON schema validator for python
28 Note: only a subset of schema features are currently supported.
29
30-See: json-schema.org for details
31+See: http://json-schema.org/ for details
32 """
33 import datetime
34 import decimal
35@@ -419,6 +419,13 @@
36 def extends(self):
37 raise NotImplementedError("extends property is not supported")
38
39+ @property
40+ def default(self):
41+ try:
42+ return self._schema["default"]
43+ except KeyError:
44+ raise SchemaError("There is no schema default for this item")
45+
46
47 class Validator(object):
48 """
49
50=== modified file 'linaro_json/tests/test_schema.py'
51--- linaro_json/tests/test_schema.py 2010-11-25 10:08:39 +0000
52+++ linaro_json/tests/test_schema.py 2010-12-01 13:32:52 +0000
53@@ -743,6 +743,17 @@
54 'raises': NotImplementedError(
55 "extends property is not supported"),
56 }),
57+ ('default_with_value', {
58+ 'schema': '{"default": 5}',
59+ 'expected': {
60+ 'default': 5
61+ }
62+ }),
63+ ('default_without_value', {
64+ 'schema': '{}',
65+ 'access': 'default',
66+ 'raises': SchemaError("There is no schema default for this item"),
67+ }),
68 ]
69
70 def test_schema_attribute(self):

Subscribers

People subscribed via source and target branches

to all changes: