diff options
author | Alexander Bayandin <a.bayandin@gmail.com> | 2014-06-20 21:21:16 +0400 |
---|---|---|
committer | Alexander Bayandin <a.bayandin@gmail.com> | 2014-06-20 21:21:51 +0400 |
commit | be5097d249858e77906f571cb433814ba8660dc5 (patch) | |
tree | 6e7a61174777198875e8a9f79256423b63bfd5e2 | |
parent | e8ba6a6b9487e6a8b74cfe6ac90852520d760523 (diff) | |
download | jsonschema-be5097d249858e77906f571cb433814ba8660dc5.tar.gz |
Workaround for tests in Python 3.4
related bug: http://bugs.python.org/issue21750
-rw-r--r-- | jsonschema/cli.py | 4 | ||||
-rw-r--r-- | jsonschema/tests/test_cli.py | 39 |
2 files changed, 24 insertions, 19 deletions
diff --git a/jsonschema/cli.py b/jsonschema/cli.py index bdde379..0126564 100644 --- a/jsonschema/cli.py +++ b/jsonschema/cli.py @@ -40,8 +40,8 @@ parser.add_argument( "-V", "--validator", type=_namedAnyWithDefault, help="the fully qualified object name of a validator to use, or, for " - "validators that are registered with jsonschema, simply the name " - "of the class.", + "validators that are registered with jsonschema, simply the name " + "of the class.", ) parser.add_argument( "schema", diff --git a/jsonschema/tests/test_cli.py b/jsonschema/tests/test_cli.py index 3f43ded..f625ca9 100644 --- a/jsonschema/tests/test_cli.py +++ b/jsonschema/tests/test_cli.py @@ -18,14 +18,19 @@ def fake_validator(*errors): class TestParser(unittest.TestCase): - FakeValidator = fake_validator() def setUp(self): - self.open = mock.mock_open(read_data='{}') - patch = mock.patch.object(cli, "open", self.open, create=True) - patch.start() - self.addCleanup(patch.stop) + mock_open = mock.mock_open() + patch_open = mock.patch.object(cli, "open", mock_open, create=True) + patch_open.start() + self.addCleanup(patch_open.stop) + + mock_json_load = mock.Mock() + mock_json_load.return_value = {} + patch_json_load = mock.patch("json.load") + patch_json_load.start() + self.addCleanup(patch_json_load.stop) def test_find_validator_by_fully_qualified_object_name(self): arguments = cli.parse_args( @@ -54,10 +59,10 @@ class TestCLI(unittest.TestCase): stdout, stderr = StringIO(), StringIO() exit_code = cli.run( { - "validator" : fake_validator(), - "schema" : {}, - "instances" : [1], - "error_format" : "{error.message}", + "validator": fake_validator(), + "schema": {}, + "instances": [1], + "error_format": "{error.message}", }, stdout=stdout, stderr=stderr, @@ -71,10 +76,10 @@ class TestCLI(unittest.TestCase): stdout, stderr = StringIO(), StringIO() exit_code = cli.run( { - "validator" : fake_validator([error]), - "schema" : {}, - "instances" : [1], - "error_format" : "{error.instance} - {error.message}", + "validator": fake_validator([error]), + "schema": {}, + "instances": [1], + "error_format": "{error.instance} - {error.message}", }, stdout=stdout, stderr=stderr, @@ -92,10 +97,10 @@ class TestCLI(unittest.TestCase): stdout, stderr = StringIO(), StringIO() exit_code = cli.run( { - "validator" : fake_validator(first_errors, second_errors), - "schema" : {}, - "instances" : [1, 2], - "error_format" : "{error.instance} - {error.message}\t", + "validator": fake_validator(first_errors, second_errors), + "schema": {}, + "instances": [1, 2], + "error_format": "{error.instance} - {error.message}\t", }, stdout=stdout, stderr=stderr, |