diff options
author | Julian Berman <Julian@GrayVines.com> | 2021-08-18 08:33:10 +0100 |
---|---|---|
committer | Julian Berman <Julian@GrayVines.com> | 2021-08-18 08:33:10 +0100 |
commit | e2a2c50618e7420101fa23a1630e881cc6408412 (patch) | |
tree | 0ede044fc8765ab6df258d101ec51df3a6c7e6c9 /jsonschema | |
parent | 00828320e6f107ceabf886eac809cd4b2a187c1e (diff) | |
download | jsonschema-e2a2c50618e7420101fa23a1630e881cc6408412.tar.gz |
Fix Draft2020-12Validator's name to be Draft202012Validator.
Diffstat (limited to 'jsonschema')
-rw-r--r-- | jsonschema/tests/test_validators.py | 8 | ||||
-rw-r--r-- | jsonschema/validators.py | 4 |
2 files changed, 11 insertions, 1 deletions
diff --git a/jsonschema/tests/test_validators.py b/jsonschema/tests/test_validators.py index 65969bd..820952d 100644 --- a/jsonschema/tests/test_validators.py +++ b/jsonschema/tests/test_validators.py @@ -84,6 +84,14 @@ class TestCreateAndExtend(SynchronousTestCase): self.addCleanup(validators.meta_schemas.pop, "something") self.assertEqual(Validator.__name__, "MyVersionValidator") + def test_dashes_are_stripped_from_validator_names(self): + Validator = validators.create( + meta_schema={u"$id": "something"}, + version="foo-bar", + ) + self.addCleanup(validators.meta_schemas.pop, "something") + self.assertEqual(Validator.__name__, "FooBarValidator") + def test_if_a_version_is_not_provided_it_is_not_registered(self): original = dict(validators.meta_schemas) validators.create(meta_schema={u"id": "id"}) diff --git a/jsonschema/validators.py b/jsonschema/validators.py index ed02767..a6c20eb 100644 --- a/jsonschema/validators.py +++ b/jsonschema/validators.py @@ -229,7 +229,9 @@ def create( if version is not None: Validator = validates(version)(Validator) - Validator.__name__ = version.title().replace(" ", "") + "Validator" + Validator.__name__ = ( + version.title().replace(" ", "").replace("-", "") + "Validator" + ) return Validator |