Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jsonschema validator with python3 #173

Closed
b4nst opened this issue Mar 14, 2016 · 2 comments
Closed

Jsonschema validator with python3 #173

b4nst opened this issue Mar 14, 2016 · 2 comments

Comments

@b4nst
Copy link

b4nst commented Mar 14, 2016

When validated extracted data against a json schema file with this kind of test :

- validators:
    - json_schema: {schema: {file: '../json-schema-folder/schema-file.json'}}

Works fine on python2.7, but with python 3.4 got this stacktrace :

Traceback (most recent call last):
  File "/usr/local/bin/resttest.py", line 4, in <module>
    resttest.command_line_run(sys.argv[1:])
  File "/usr/local/lib/python3.4/dist-packages/pyresttest/resttest.py", line 911, in command_line_run
    main(args)
  File "/usr/local/lib/python3.4/dist-packages/pyresttest/resttest.py", line 853, in main
    failures = run_testsets(tests)
  File "/usr/local/lib/python3.4/dist-packages/pyresttest/resttest.py", line 654, in run_testsets
    result = run_test(test, test_config=myconfig, context=context, curl_handle=curl_handle)
  File "/usr/local/lib/python3.4/dist-packages/pyresttest/resttest.py", line 409, in run_test
    body=body, headers=head, context=my_context)
  File "/usr/local/lib/python3.4/dist-packages/pyresttest/ext/validator_jsonschema.py", line 30, in validate
    jsonschema.validate(json.loads(body), schema)
  File "/usr/lib/python3.4/json/__init__.py", line 312, in loads
    s.__class__.__name__))
TypeError: the JSON object must be str, not 'bytes'
@b4nst b4nst changed the title Jsonschema with python3 Jsonschema validator with python3 Mar 14, 2016
@svanoort svanoort added the bug label Mar 15, 2016
@svanoort
Copy link
Owner

Hi @bastienar -
Thank you for reporting the issue - I've fixed the bug, added a testcase to cover it, verified it against the environments, and released it to the public. You have, of course, received credit in the changelog for spotting this. ;)

v1.7.1 includes the fix (also on the master & stable brancesh if you're cloning from source).

Thanks!
Sam

@b4nst
Copy link
Author

b4nst commented Mar 15, 2016

Wow, such reactivity ! I confirm it works fine now, thank you very much.

Bastien.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants