Test failures when rfc3987 is installed
mgorny opened this issue · comments
When rfc3987
package is installed in the test environment, the tests fail. I think it enables some additional checks in jsonschema.
The easiest way to reproduce is to add it to deps
in tox:
diff --git a/tox.ini b/tox.ini
index 162badb..83f2579 100644
--- a/tox.ini
+++ b/tox.ini
@@ -6,6 +6,7 @@ skip_missing_interpreters = true
deps =
jsonschema>=3.0.0
nose>=1.3.0
+ rfc3987
coverage
commands =
nosetests --with-coverage \
$ python3.9 -m nose
..........................................EE......EE....E..............................................
======================================================================
ERROR: test_add_other (test.test_builder.TestInteraction)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/GenSON/.tox/py39/lib/python3.9/site-packages/jsonschema/_format.py", line 135, in check
result = func(instance)
File "/tmp/GenSON/.tox/py39/lib/python3.9/site-packages/jsonschema/_format.py", line 348, in is_uri
return rfc3987.parse(instance, rule="URI")
File "/tmp/GenSON/.tox/py39/lib/python3.9/site-packages/rfc3987.py", line 462, in parse
raise ValueError('%r is not a valid %r.' % (string, rule))
ValueError: 'TEST_URI' is not a valid 'URI'.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/tmp/GenSON/test/test_builder.py", line 63, in test_add_other
self.assertResult({
File "/tmp/GenSON/test/base.py", line 39, in assertResult
self.assertUserContract()
File "/tmp/GenSON/test/base.py", line 42, in assertUserContract
self._assertSchemaIsValid()
File "/tmp/GenSON/test/base.py", line 46, in _assertSchemaIsValid
jsonschema.Draft7Validator.check_schema(self.builder.to_schema())
File "/tmp/GenSON/.tox/py39/lib/python3.9/site-packages/jsonschema/validators.py", line 231, in check_schema
raise exceptions.SchemaError.create_from(error)
jsonschema.exceptions.SchemaError: 'TEST_URI' is not a 'uri'
Failed validating 'format' in metaschema['properties']['$schema']:
{'format': 'uri', 'type': 'string'}
On schema['$schema']:
'TEST_URI'
======================================================================
ERROR: test_add_other_no_uri_overwrite (test.test_builder.TestInteraction)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/GenSON/.tox/py39/lib/python3.9/site-packages/jsonschema/_format.py", line 135, in check
result = func(instance)
File "/tmp/GenSON/.tox/py39/lib/python3.9/site-packages/jsonschema/_format.py", line 348, in is_uri
return rfc3987.parse(instance, rule="URI")
File "/tmp/GenSON/.tox/py39/lib/python3.9/site-packages/rfc3987.py", line 462, in parse
raise ValueError('%r is not a valid %r.' % (string, rule))
ValueError: 'TEST_URI' is not a valid 'URI'.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/tmp/GenSON/test/test_builder.py", line 74, in test_add_other_no_uri_overwrite
self.assertResult({
File "/tmp/GenSON/test/base.py", line 39, in assertResult
self.assertUserContract()
File "/tmp/GenSON/test/base.py", line 42, in assertUserContract
self._assertSchemaIsValid()
File "/tmp/GenSON/test/base.py", line 46, in _assertSchemaIsValid
jsonschema.Draft7Validator.check_schema(self.builder.to_schema())
File "/tmp/GenSON/.tox/py39/lib/python3.9/site-packages/jsonschema/validators.py", line 231, in check_schema
raise exceptions.SchemaError.create_from(error)
jsonschema.exceptions.SchemaError: 'TEST_URI' is not a 'uri'
Failed validating 'format' in metaschema['properties']['$schema']:
{'format': 'uri', 'type': 'string'}
On schema['$schema']:
'TEST_URI'
======================================================================
ERROR: test_add_schema_with_uri_default (test.test_builder.TestMethods)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/GenSON/.tox/py39/lib/python3.9/site-packages/jsonschema/_format.py", line 135, in check
result = func(instance)
File "/tmp/GenSON/.tox/py39/lib/python3.9/site-packages/jsonschema/_format.py", line 348, in is_uri
return rfc3987.parse(instance, rule="URI")
File "/tmp/GenSON/.tox/py39/lib/python3.9/site-packages/rfc3987.py", line 462, in parse
raise ValueError('%r is not a valid %r.' % (string, rule))
ValueError: 'TEST_URI' is not a valid 'URI'.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/tmp/GenSON/test/test_builder.py", line 39, in test_add_schema_with_uri_default
self.assertResult({"$schema": test_uri, "type": "null"})
File "/tmp/GenSON/test/base.py", line 39, in assertResult
self.assertUserContract()
File "/tmp/GenSON/test/base.py", line 42, in assertUserContract
self._assertSchemaIsValid()
File "/tmp/GenSON/test/base.py", line 46, in _assertSchemaIsValid
jsonschema.Draft7Validator.check_schema(self.builder.to_schema())
File "/tmp/GenSON/.tox/py39/lib/python3.9/site-packages/jsonschema/validators.py", line 231, in check_schema
raise exceptions.SchemaError.create_from(error)
jsonschema.exceptions.SchemaError: 'TEST_URI' is not a 'uri'
Failed validating 'format' in metaschema['properties']['$schema']:
{'format': 'uri', 'type': 'string'}
On schema['$schema']:
'TEST_URI'
======================================================================
ERROR: test_add_schema_with_uri_not_defuult (test.test_builder.TestMethods)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/GenSON/.tox/py39/lib/python3.9/site-packages/jsonschema/_format.py", line 135, in check
result = func(instance)
File "/tmp/GenSON/.tox/py39/lib/python3.9/site-packages/jsonschema/_format.py", line 348, in is_uri
return rfc3987.parse(instance, rule="URI")
File "/tmp/GenSON/.tox/py39/lib/python3.9/site-packages/rfc3987.py", line 462, in parse
raise ValueError('%r is not a valid %r.' % (string, rule))
ValueError: 'TEST_URI' is not a valid 'URI'.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/tmp/GenSON/test/test_builder.py", line 45, in test_add_schema_with_uri_not_defuult
self.assertResult({"$schema": test_uri, "type": "null"})
File "/tmp/GenSON/test/base.py", line 39, in assertResult
self.assertUserContract()
File "/tmp/GenSON/test/base.py", line 42, in assertUserContract
self._assertSchemaIsValid()
File "/tmp/GenSON/test/base.py", line 46, in _assertSchemaIsValid
jsonschema.Draft7Validator.check_schema(self.builder.to_schema())
File "/tmp/GenSON/.tox/py39/lib/python3.9/site-packages/jsonschema/validators.py", line 231, in check_schema
raise exceptions.SchemaError.create_from(error)
jsonschema.exceptions.SchemaError: 'TEST_URI' is not a 'uri'
Failed validating 'format' in metaschema['properties']['$schema']:
{'format': 'uri', 'type': 'string'}
On schema['$schema']:
'TEST_URI'
======================================================================
ERROR: test_uri (test.test_builder.TestParams)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/GenSON/.tox/py39/lib/python3.9/site-packages/jsonschema/_format.py", line 135, in check
result = func(instance)
File "/tmp/GenSON/.tox/py39/lib/python3.9/site-packages/jsonschema/_format.py", line 348, in is_uri
return rfc3987.parse(instance, rule="URI")
File "/tmp/GenSON/.tox/py39/lib/python3.9/site-packages/rfc3987.py", line 462, in parse
raise ValueError('%r is not a valid %r.' % (string, rule))
ValueError: 'TEST_URI' is not a valid 'URI'.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/tmp/GenSON/test/test_builder.py", line 10, in test_uri
self.assertResult({"$schema": test_uri})
File "/tmp/GenSON/test/base.py", line 39, in assertResult
self.assertUserContract()
File "/tmp/GenSON/test/base.py", line 42, in assertUserContract
self._assertSchemaIsValid()
File "/tmp/GenSON/test/base.py", line 46, in _assertSchemaIsValid
jsonschema.Draft7Validator.check_schema(self.builder.to_schema())
File "/tmp/GenSON/.tox/py39/lib/python3.9/site-packages/jsonschema/validators.py", line 231, in check_schema
raise exceptions.SchemaError.create_from(error)
jsonschema.exceptions.SchemaError: 'TEST_URI' is not a 'uri'
Failed validating 'format' in metaschema['properties']['$schema']:
{'format': 'uri', 'type': 'string'}
On schema['$schema']:
'TEST_URI'
----------------------------------------------------------------------
Ran 103 tests in 1.091s
FAILED (errors=5)
FWICS I can resolve it by replacing all instances of TEST_URI
with test://
(i.e. something that looks like a URI). I'll submit a PR shortly.
This issue should've been auto-closed a while ago. Closing now.