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

Test failures when rfc3987 is installed #69

Closed
mgorny opened this issue Mar 30, 2023 · 2 comments · May be fixed by #70
Closed

Test failures when rfc3987 is installed #69

mgorny opened this issue Mar 30, 2023 · 2 comments · May be fixed by #70

Comments

@mgorny
Copy link

mgorny commented Mar 30, 2023

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)
@mgorny
Copy link
Author

mgorny commented Mar 30, 2023

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.

mgorny added a commit to mgorny/GenSON that referenced this issue Mar 30, 2023
Use a quasi-valid URI of "test://" instead of plain "TEST_URI"
in test_builder.  This avoids parsing failures from jsonschema
if rfc3987 is installed in the test environment.

Fixes wolverdude#69
@wolverdude
Copy link
Owner

This issue should've been auto-closed a while ago. Closing now.

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

Successfully merging a pull request may close this issue.

2 participants