ADAPT-Chase commited on
Commit
668155e
·
verified ·
1 Parent(s): bebcc40

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +1 -0
  2. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema-4.20.0.dist-info/licenses/COPYING +19 -0
  3. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/__init__.cpython-312.pyc +0 -0
  4. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/__main__.cpython-312.pyc +0 -0
  5. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/_format.cpython-312.pyc +0 -0
  6. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/_keywords.cpython-312.pyc +0 -0
  7. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/_legacy_keywords.cpython-312.pyc +0 -0
  8. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/_types.cpython-312.pyc +0 -0
  9. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/_typing.cpython-312.pyc +0 -0
  10. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/_utils.cpython-312.pyc +0 -0
  11. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/cli.cpython-312.pyc +0 -0
  12. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/exceptions.cpython-312.pyc +0 -0
  13. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/protocols.cpython-312.pyc +0 -0
  14. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/validators.cpython-312.pyc +0 -0
  15. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__init__.py +5 -0
  16. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/__init__.cpython-312.pyc +0 -0
  17. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/issue232.cpython-312.pyc +0 -0
  18. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/json_schema_test_suite.cpython-312.pyc +0 -0
  19. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/nested_schemas.cpython-312.pyc +0 -0
  20. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/subcomponents.cpython-312.pyc +0 -0
  21. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/unused_registry.cpython-312.pyc +0 -0
  22. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/validator_creation.cpython-312.pyc +0 -0
  23. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/issue232.py +25 -0
  24. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/issue232/issue.json +0 -0
  25. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/json_schema_test_suite.py +12 -0
  26. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/nested_schemas.py +56 -0
  27. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/subcomponents.py +42 -0
  28. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/unused_registry.py +35 -0
  29. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/validator_creation.py +14 -0
  30. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/__init__.py +0 -0
  31. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/__init__.cpython-312.pyc +0 -0
  32. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/_suite.cpython-312.pyc +0 -0
  33. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/fuzz_validate.cpython-312.pyc +0 -0
  34. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_cli.cpython-312.pyc +0 -0
  35. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_deprecations.cpython-312.pyc +0 -0
  36. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_exceptions.cpython-312.pyc +0 -0
  37. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_format.cpython-312.pyc +0 -0
  38. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_jsonschema_test_suite.cpython-312.pyc +0 -0
  39. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_types.cpython-312.pyc +0 -0
  40. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_utils.cpython-312.pyc +0 -0
  41. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_validators.cpython-312.pyc +3 -0
  42. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/_suite.py +274 -0
  43. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/fuzz_validate.py +50 -0
  44. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/test_cli.py +907 -0
  45. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/test_deprecations.py +431 -0
  46. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/test_exceptions.py +617 -0
  47. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/test_format.py +91 -0
  48. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/test_jsonschema_test_suite.py +257 -0
  49. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/test_types.py +221 -0
  50. platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/test_utils.py +124 -0
.gitattributes CHANGED
@@ -3506,3 +3506,4 @@ platform/dataops/dto/.venv/lib/python3.12/site-packages/mkdocs/themes/readthedoc
3506
  platform/dataops/dto/.venv/lib/python3.12/site-packages/mkdocs/themes/readthedocs/css/fonts/lato-normal-italic.woff2 filter=lfs diff=lfs merge=lfs -text
3507
  platform/dataops/dto/.venv/lib/python3.12/site-packages/mkdocs/themes/readthedocs/css/fonts/lato-normal.woff filter=lfs diff=lfs merge=lfs -text
3508
  platform/dataops/dto/.venv/lib/python3.12/site-packages/mkdocs/themes/readthedocs/css/fonts/lato-normal.woff2 filter=lfs diff=lfs merge=lfs -text
 
 
3506
  platform/dataops/dto/.venv/lib/python3.12/site-packages/mkdocs/themes/readthedocs/css/fonts/lato-normal-italic.woff2 filter=lfs diff=lfs merge=lfs -text
3507
  platform/dataops/dto/.venv/lib/python3.12/site-packages/mkdocs/themes/readthedocs/css/fonts/lato-normal.woff filter=lfs diff=lfs merge=lfs -text
3508
  platform/dataops/dto/.venv/lib/python3.12/site-packages/mkdocs/themes/readthedocs/css/fonts/lato-normal.woff2 filter=lfs diff=lfs merge=lfs -text
3509
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_validators.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema-4.20.0.dist-info/licenses/COPYING ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2013 Julian Berman
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (3.78 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/__main__.cpython-312.pyc ADDED
Binary file (344 Bytes). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/_format.cpython-312.pyc ADDED
Binary file (17.8 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/_keywords.cpython-312.pyc ADDED
Binary file (19.4 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/_legacy_keywords.cpython-312.pyc ADDED
Binary file (17.2 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/_types.cpython-312.pyc ADDED
Binary file (7.04 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/_typing.cpython-312.pyc ADDED
Binary file (1.33 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/_utils.cpython-312.pyc ADDED
Binary file (13.7 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/cli.cpython-312.pyc ADDED
Binary file (12.3 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/exceptions.cpython-312.pyc ADDED
Binary file (20.9 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/protocols.cpython-312.pyc ADDED
Binary file (6.79 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/validators.cpython-312.pyc ADDED
Binary file (52.1 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__init__.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ """
2
+ Benchmarks for validation.
3
+
4
+ This package is *not* public API.
5
+ """
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (280 Bytes). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/issue232.cpython-312.pyc ADDED
Binary file (905 Bytes). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/json_schema_test_suite.cpython-312.pyc ADDED
Binary file (650 Bytes). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/nested_schemas.cpython-312.pyc ADDED
Binary file (2.48 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/subcomponents.cpython-312.pyc ADDED
Binary file (2.28 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/unused_registry.cpython-312.pyc ADDED
Binary file (1.59 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/validator_creation.cpython-312.pyc ADDED
Binary file (570 Bytes). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/issue232.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ A performance benchmark using the example from issue #232.
3
+
4
+ See https://github.com/python-jsonschema/jsonschema/pull/232.
5
+ """
6
+ from pathlib import Path
7
+
8
+ from pyperf import Runner
9
+ from referencing import Registry
10
+
11
+ from jsonschema.tests._suite import Version
12
+ import jsonschema
13
+
14
+ issue232 = Version(
15
+ path=Path(__file__).parent / "issue232",
16
+ remotes=Registry(),
17
+ name="issue232",
18
+ )
19
+
20
+
21
+ if __name__ == "__main__":
22
+ issue232.benchmark(
23
+ runner=Runner(),
24
+ Validator=jsonschema.Draft4Validator,
25
+ )
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/issue232/issue.json ADDED
The diff for this file is too large to render. See raw diff
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/json_schema_test_suite.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ A performance benchmark using the official test suite.
3
+
4
+ This benchmarks jsonschema using every valid example in the
5
+ JSON-Schema-Test-Suite. It will take some time to complete.
6
+ """
7
+ from pyperf import Runner
8
+
9
+ from jsonschema.tests._suite import Suite
10
+
11
+ if __name__ == "__main__":
12
+ Suite().benchmark(runner=Runner())
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/nested_schemas.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Validating highly nested schemas shouldn't cause exponential time blowups.
3
+
4
+ See https://github.com/python-jsonschema/jsonschema/issues/1097.
5
+ """
6
+ from itertools import cycle
7
+
8
+ from jsonschema.validators import validator_for
9
+
10
+ metaschemaish = {
11
+ "$id": "https://example.com/draft/2020-12/schema/strict",
12
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
13
+
14
+ "$vocabulary": {
15
+ "https://json-schema.org/draft/2020-12/vocab/core": True,
16
+ "https://json-schema.org/draft/2020-12/vocab/applicator": True,
17
+ "https://json-schema.org/draft/2020-12/vocab/unevaluated": True,
18
+ "https://json-schema.org/draft/2020-12/vocab/validation": True,
19
+ "https://json-schema.org/draft/2020-12/vocab/meta-data": True,
20
+ "https://json-schema.org/draft/2020-12/vocab/format-annotation": True,
21
+ "https://json-schema.org/draft/2020-12/vocab/content": True
22
+ },
23
+ "$dynamicAnchor": "meta",
24
+
25
+ "$ref": "https://json-schema.org/draft/2020-12/schema",
26
+ "unevaluatedProperties": False,
27
+ }
28
+
29
+
30
+ def nested_schema(levels):
31
+ """
32
+ Produce a schema which validates deeply nested objects and arrays.
33
+ """
34
+
35
+ names = cycle(["foo", "bar", "baz", "quux", "spam", "eggs"])
36
+ schema = {"type": "object", "properties": {"ham": {"type": "string"}}}
37
+ for _, name in zip(range(levels - 1), names):
38
+ schema = {"type": "object", "properties": {name: schema}}
39
+ return schema
40
+
41
+
42
+ validator = validator_for(metaschemaish)(metaschemaish)
43
+
44
+ if __name__ == "__main__":
45
+ from pyperf import Runner
46
+ runner = Runner()
47
+
48
+ not_nested = nested_schema(levels=1)
49
+ runner.bench_func("not nested", lambda: validator.is_valid(not_nested))
50
+
51
+ for levels in range(1, 11, 3):
52
+ schema = nested_schema(levels=levels)
53
+ runner.bench_func(
54
+ f"nested * {levels}",
55
+ lambda schema=schema: validator.is_valid(schema),
56
+ )
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/subcomponents.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ A benchmark which tries to compare the possible slow subparts of validation.
3
+ """
4
+ from referencing import Registry
5
+ from referencing.jsonschema import DRAFT202012
6
+ from rpds import HashTrieMap, HashTrieSet
7
+
8
+ from jsonschema import Draft202012Validator
9
+
10
+ schema = {
11
+ "type": "array",
12
+ "minLength": 1,
13
+ "maxLength": 1,
14
+ "items": {"type": "integer"}
15
+ }
16
+
17
+ hmap = HashTrieMap()
18
+ hset = HashTrieSet()
19
+
20
+ registry = Registry()
21
+
22
+ v = Draft202012Validator(schema)
23
+
24
+
25
+ def registry_data_structures():
26
+ return hmap.insert("foo", "bar"), hset.insert("foo")
27
+
28
+
29
+ def registry_add():
30
+ resource = DRAFT202012.create_resource(schema)
31
+ return registry.with_resource(uri="urn:example", resource=resource)
32
+
33
+
34
+ if __name__ == "__main__":
35
+ from pyperf import Runner
36
+ runner = Runner()
37
+
38
+ runner.bench_func("HashMap/HashSet insertion", registry_data_structures)
39
+ runner.bench_func("Registry insertion", registry_add)
40
+ runner.bench_func("Success", lambda: v.is_valid([1]))
41
+ runner.bench_func("Failure", lambda: v.is_valid(["foo"]))
42
+ runner.bench_func("Metaschema validation", lambda: v.check_schema(schema))
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/unused_registry.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ An unused schema registry should not cause slower validation.
3
+
4
+ "Unused" here means one where no reference resolution is occurring anyhow.
5
+
6
+ See https://github.com/python-jsonschema/jsonschema/issues/1088.
7
+ """
8
+ from pyperf import Runner
9
+ from referencing import Registry
10
+ from referencing.jsonschema import DRAFT201909
11
+
12
+ from jsonschema import Draft201909Validator
13
+
14
+ registry = Registry().with_resource(
15
+ "urn:example:foo",
16
+ DRAFT201909.create_resource({})
17
+ )
18
+
19
+ schema = {"$ref": "https://json-schema.org/draft/2019-09/schema"}
20
+ instance = {"maxLength": 4}
21
+
22
+ no_registry = Draft201909Validator(schema)
23
+ with_useless_registry = Draft201909Validator(schema, registry=registry)
24
+
25
+ if __name__ == "__main__":
26
+ runner = Runner()
27
+
28
+ runner.bench_func(
29
+ "no registry",
30
+ lambda: no_registry.is_valid(instance),
31
+ )
32
+ runner.bench_func(
33
+ "useless registry",
34
+ lambda: with_useless_registry.is_valid(instance),
35
+ )
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/validator_creation.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pyperf import Runner
2
+
3
+ from jsonschema import Draft202012Validator
4
+
5
+ schema = {
6
+ "type": "array",
7
+ "minLength": 1,
8
+ "maxLength": 1,
9
+ "items": {"type": "integer"},
10
+ }
11
+
12
+
13
+ if __name__ == "__main__":
14
+ Runner().bench_func("validator creation", Draft202012Validator, schema)
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/__init__.py ADDED
File without changes
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (195 Bytes). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/_suite.cpython-312.pyc ADDED
Binary file (13.2 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/fuzz_validate.cpython-312.pyc ADDED
Binary file (2.34 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_cli.cpython-312.pyc ADDED
Binary file (33.5 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_deprecations.cpython-312.pyc ADDED
Binary file (25.3 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_exceptions.cpython-312.pyc ADDED
Binary file (27.2 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_format.cpython-312.pyc ADDED
Binary file (6.47 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_jsonschema_test_suite.cpython-312.pyc ADDED
Binary file (9.97 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_types.cpython-312.pyc ADDED
Binary file (11.9 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_utils.cpython-312.pyc ADDED
Binary file (7.04 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_validators.cpython-312.pyc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b4a0019b4c77e427afbc2c831e35a7860ae7cc1b29d70bdfe369a44a2f8ca706
3
+ size 130088
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/_suite.py ADDED
@@ -0,0 +1,274 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Python representations of the JSON Schema Test Suite tests.
3
+ """
4
+ from __future__ import annotations
5
+
6
+ from collections.abc import Iterable, Mapping
7
+ from contextlib import suppress
8
+ from functools import partial
9
+ from pathlib import Path
10
+ from typing import TYPE_CHECKING, Any
11
+ import json
12
+ import os
13
+ import re
14
+ import subprocess
15
+ import sys
16
+ import unittest
17
+
18
+ from attrs import field, frozen
19
+ from referencing import Registry
20
+ import referencing.jsonschema
21
+
22
+ if TYPE_CHECKING:
23
+ import pyperf
24
+
25
+ from jsonschema.validators import _VALIDATORS
26
+ import jsonschema
27
+
28
+ _DELIMITERS = re.compile(r"[\W\- ]+")
29
+
30
+
31
+ def _find_suite():
32
+ root = os.environ.get("JSON_SCHEMA_TEST_SUITE")
33
+ if root is not None:
34
+ return Path(root)
35
+
36
+ root = Path(jsonschema.__file__).parent.parent / "json"
37
+ if not root.is_dir(): # pragma: no cover
38
+ raise ValueError(
39
+ (
40
+ "Can't find the JSON-Schema-Test-Suite directory. "
41
+ "Set the 'JSON_SCHEMA_TEST_SUITE' environment "
42
+ "variable or run the tests from alongside a checkout "
43
+ "of the suite."
44
+ ),
45
+ )
46
+ return root
47
+
48
+
49
+ @frozen
50
+ class Suite:
51
+
52
+ _root: Path = field(factory=_find_suite)
53
+ _remotes: referencing.jsonschema.SchemaRegistry = field(init=False)
54
+
55
+ def __attrs_post_init__(self):
56
+ jsonschema_suite = self._root.joinpath("bin", "jsonschema_suite")
57
+ argv = [sys.executable, str(jsonschema_suite), "remotes"]
58
+ remotes = subprocess.check_output(argv).decode("utf-8")
59
+
60
+ resources = json.loads(remotes)
61
+
62
+ li = "http://localhost:1234/locationIndependentIdentifierPre2019.json"
63
+ li4 = "http://localhost:1234/locationIndependentIdentifierDraft4.json"
64
+
65
+ registry = Registry().with_resources(
66
+ [
67
+ (
68
+ li,
69
+ referencing.jsonschema.DRAFT7.create_resource(
70
+ contents=resources.pop(li),
71
+ ),
72
+ ),
73
+ (
74
+ li4,
75
+ referencing.jsonschema.DRAFT4.create_resource(
76
+ contents=resources.pop(li4),
77
+ ),
78
+ ),
79
+ ],
80
+ ).with_contents(
81
+ resources.items(),
82
+ default_specification=referencing.jsonschema.DRAFT202012,
83
+ )
84
+ object.__setattr__(self, "_remotes", registry)
85
+
86
+ def benchmark(self, runner: pyperf.Runner): # pragma: no cover
87
+ for name, Validator in _VALIDATORS.items():
88
+ self.version(name=name).benchmark(
89
+ runner=runner,
90
+ Validator=Validator,
91
+ )
92
+
93
+ def version(self, name) -> Version:
94
+ return Version(
95
+ name=name,
96
+ path=self._root / "tests" / name,
97
+ remotes=self._remotes,
98
+ )
99
+
100
+
101
+ @frozen
102
+ class Version:
103
+
104
+ _path: Path
105
+ _remotes: referencing.jsonschema.SchemaRegistry
106
+
107
+ name: str
108
+
109
+ def benchmark(self, **kwargs): # pragma: no cover
110
+ for case in self.cases():
111
+ case.benchmark(**kwargs)
112
+
113
+ def cases(self) -> Iterable[_Case]:
114
+ return self._cases_in(paths=self._path.glob("*.json"))
115
+
116
+ def format_cases(self) -> Iterable[_Case]:
117
+ return self._cases_in(paths=self._path.glob("optional/format/*.json"))
118
+
119
+ def optional_cases_of(self, name: str) -> Iterable[_Case]:
120
+ return self._cases_in(paths=[self._path / "optional" / f"{name}.json"])
121
+
122
+ def to_unittest_testcase(self, *groups, **kwargs):
123
+ name = kwargs.pop("name", "Test" + self.name.title().replace("-", ""))
124
+ methods = {
125
+ method.__name__: method
126
+ for method in (
127
+ test.to_unittest_method(**kwargs)
128
+ for group in groups
129
+ for case in group
130
+ for test in case.tests
131
+ )
132
+ }
133
+ cls = type(name, (unittest.TestCase,), methods)
134
+
135
+ # We're doing crazy things, so if they go wrong, like a function
136
+ # behaving differently on some other interpreter, just make them
137
+ # not happen.
138
+ with suppress(Exception):
139
+ cls.__module__ = _someone_save_us_the_module_of_the_caller()
140
+
141
+ return cls
142
+
143
+ def _cases_in(self, paths: Iterable[Path]) -> Iterable[_Case]:
144
+ for path in paths:
145
+ for case in json.loads(path.read_text(encoding="utf-8")):
146
+ yield _Case.from_dict(
147
+ case,
148
+ version=self,
149
+ subject=path.stem,
150
+ remotes=self._remotes,
151
+ )
152
+
153
+
154
+ @frozen
155
+ class _Case:
156
+
157
+ version: Version
158
+
159
+ subject: str
160
+ description: str
161
+ schema: Mapping[str, Any] | bool
162
+ tests: list[_Test]
163
+ comment: str | None = None
164
+
165
+ @classmethod
166
+ def from_dict(cls, data, remotes, **kwargs):
167
+ data.update(kwargs)
168
+ tests = [
169
+ _Test(
170
+ version=data["version"],
171
+ subject=data["subject"],
172
+ case_description=data["description"],
173
+ schema=data["schema"],
174
+ remotes=remotes,
175
+ **test,
176
+ ) for test in data.pop("tests")
177
+ ]
178
+ return cls(tests=tests, **data)
179
+
180
+ def benchmark(self, runner: pyperf.Runner, **kwargs): # pragma: no cover
181
+ for test in self.tests:
182
+ runner.bench_func(
183
+ test.fully_qualified_name,
184
+ partial(test.validate_ignoring_errors, **kwargs),
185
+ )
186
+
187
+
188
+ @frozen(repr=False)
189
+ class _Test:
190
+
191
+ version: Version
192
+
193
+ subject: str
194
+ case_description: str
195
+ description: str
196
+
197
+ data: Any
198
+ schema: Mapping[str, Any] | bool
199
+
200
+ valid: bool
201
+
202
+ _remotes: referencing.jsonschema.SchemaRegistry
203
+
204
+ comment: str | None = None
205
+
206
+ def __repr__(self): # pragma: no cover
207
+ return f"<Test {self.fully_qualified_name}>"
208
+
209
+ @property
210
+ def fully_qualified_name(self): # pragma: no cover
211
+ return " > ".join(
212
+ [
213
+ self.version.name,
214
+ self.subject,
215
+ self.case_description,
216
+ self.description,
217
+ ],
218
+ )
219
+
220
+ def to_unittest_method(self, skip=lambda test: None, **kwargs):
221
+ if self.valid:
222
+ def fn(this):
223
+ self.validate(**kwargs)
224
+ else:
225
+ def fn(this):
226
+ with this.assertRaises(jsonschema.ValidationError):
227
+ self.validate(**kwargs)
228
+
229
+ fn.__name__ = "_".join(
230
+ [
231
+ "test",
232
+ _DELIMITERS.sub("_", self.subject),
233
+ _DELIMITERS.sub("_", self.case_description),
234
+ _DELIMITERS.sub("_", self.description),
235
+ ],
236
+ )
237
+ reason = skip(self)
238
+ if reason is None or os.environ.get("JSON_SCHEMA_DEBUG", "0") != "0":
239
+ return fn
240
+ elif os.environ.get("JSON_SCHEMA_EXPECTED_FAILURES", "0") != "0": # pragma: no cover # noqa: E501
241
+ return unittest.expectedFailure(fn)
242
+ else:
243
+ return unittest.skip(reason)(fn)
244
+
245
+ def validate(self, Validator, **kwargs):
246
+ Validator.check_schema(self.schema)
247
+ validator = Validator(
248
+ schema=self.schema,
249
+ registry=self._remotes,
250
+ **kwargs,
251
+ )
252
+ if os.environ.get("JSON_SCHEMA_DEBUG", "0") != "0": # pragma: no cover
253
+ breakpoint()
254
+ validator.validate(instance=self.data)
255
+
256
+ def validate_ignoring_errors(self, Validator): # pragma: no cover
257
+ with suppress(jsonschema.ValidationError):
258
+ self.validate(Validator=Validator)
259
+
260
+
261
+ def _someone_save_us_the_module_of_the_caller():
262
+ """
263
+ The FQON of the module 2nd stack frames up from here.
264
+
265
+ This is intended to allow us to dynamically return test case classes that
266
+ are indistinguishable from being defined in the module that wants them.
267
+
268
+ Otherwise, trial will mis-print the FQON, and copy pasting it won't re-run
269
+ the class that really is running.
270
+
271
+ Save us all, this is all so so so so so terrible.
272
+ """
273
+
274
+ return sys._getframe(2).f_globals["__name__"]
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/fuzz_validate.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Fuzzing setup for OSS-Fuzz.
3
+
4
+ See https://github.com/google/oss-fuzz/tree/master/projects/jsonschema for the
5
+ other half of the setup here.
6
+ """
7
+ import sys
8
+
9
+ from hypothesis import given, strategies
10
+
11
+ import jsonschema
12
+
13
+ PRIM = strategies.one_of(
14
+ strategies.booleans(),
15
+ strategies.integers(),
16
+ strategies.floats(allow_nan=False, allow_infinity=False),
17
+ strategies.text(),
18
+ )
19
+ DICT = strategies.recursive(
20
+ base=strategies.one_of(
21
+ strategies.booleans(),
22
+ strategies.dictionaries(strategies.text(), PRIM),
23
+ ),
24
+ extend=lambda inner: strategies.dictionaries(strategies.text(), inner),
25
+ )
26
+
27
+
28
+ @given(obj1=DICT, obj2=DICT)
29
+ def test_schemas(obj1, obj2):
30
+ try:
31
+ jsonschema.validate(instance=obj1, schema=obj2)
32
+ except jsonschema.exceptions.ValidationError:
33
+ pass
34
+ except jsonschema.exceptions.SchemaError:
35
+ pass
36
+
37
+
38
+ def main():
39
+ atheris.instrument_all()
40
+ atheris.Setup(
41
+ sys.argv,
42
+ test_schemas.hypothesis.fuzz_one_input,
43
+ enable_python_coverage=True,
44
+ )
45
+ atheris.Fuzz()
46
+
47
+
48
+ if __name__ == "__main__":
49
+ import atheris
50
+ main()
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/test_cli.py ADDED
@@ -0,0 +1,907 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from contextlib import redirect_stderr, redirect_stdout
2
+ from importlib import metadata
3
+ from io import StringIO
4
+ from json import JSONDecodeError
5
+ from pathlib import Path
6
+ from textwrap import dedent
7
+ from unittest import TestCase
8
+ import json
9
+ import os
10
+ import subprocess
11
+ import sys
12
+ import tempfile
13
+ import warnings
14
+
15
+ from jsonschema import Draft4Validator, Draft202012Validator
16
+ from jsonschema.exceptions import (
17
+ SchemaError,
18
+ ValidationError,
19
+ _RefResolutionError,
20
+ )
21
+ from jsonschema.validators import _LATEST_VERSION, validate
22
+
23
+ with warnings.catch_warnings():
24
+ warnings.simplefilter("ignore")
25
+ from jsonschema import cli
26
+
27
+
28
+ def fake_validator(*errors):
29
+ errors = list(reversed(errors))
30
+
31
+ class FakeValidator:
32
+ def __init__(self, *args, **kwargs):
33
+ pass
34
+
35
+ def iter_errors(self, instance):
36
+ if errors:
37
+ return errors.pop()
38
+ return [] # pragma: no cover
39
+
40
+ @classmethod
41
+ def check_schema(self, schema):
42
+ pass
43
+
44
+ return FakeValidator
45
+
46
+
47
+ def fake_open(all_contents):
48
+ def open(path):
49
+ contents = all_contents.get(path)
50
+ if contents is None:
51
+ raise FileNotFoundError(path)
52
+ return StringIO(contents)
53
+ return open
54
+
55
+
56
+ def _message_for(non_json):
57
+ try:
58
+ json.loads(non_json)
59
+ except JSONDecodeError as error:
60
+ return str(error)
61
+ else: # pragma: no cover
62
+ raise RuntimeError("Tried and failed to capture a JSON dump error.")
63
+
64
+
65
+ class TestCLI(TestCase):
66
+ def run_cli(
67
+ self, argv, files=None, stdin=StringIO(), exit_code=0, **override,
68
+ ):
69
+ arguments = cli.parse_args(argv)
70
+ arguments.update(override)
71
+
72
+ self.assertFalse(hasattr(cli, "open"))
73
+ cli.open = fake_open(files or {})
74
+ try:
75
+ stdout, stderr = StringIO(), StringIO()
76
+ actual_exit_code = cli.run(
77
+ arguments,
78
+ stdin=stdin,
79
+ stdout=stdout,
80
+ stderr=stderr,
81
+ )
82
+ finally:
83
+ del cli.open
84
+
85
+ self.assertEqual(
86
+ actual_exit_code, exit_code, msg=dedent(
87
+ f"""
88
+ Expected an exit code of {exit_code} != {actual_exit_code}.
89
+
90
+ stdout: {stdout.getvalue()}
91
+
92
+ stderr: {stderr.getvalue()}
93
+ """,
94
+ ),
95
+ )
96
+ return stdout.getvalue(), stderr.getvalue()
97
+
98
+ def assertOutputs(self, stdout="", stderr="", **kwargs):
99
+ self.assertEqual(
100
+ self.run_cli(**kwargs),
101
+ (dedent(stdout), dedent(stderr)),
102
+ )
103
+
104
+ def test_invalid_instance(self):
105
+ error = ValidationError("I am an error!", instance=12)
106
+ self.assertOutputs(
107
+ files=dict(
108
+ some_schema='{"does not": "matter since it is stubbed"}',
109
+ some_instance=json.dumps(error.instance),
110
+ ),
111
+ validator=fake_validator([error]),
112
+
113
+ argv=["-i", "some_instance", "some_schema"],
114
+
115
+ exit_code=1,
116
+ stderr="12: I am an error!\n",
117
+ )
118
+
119
+ def test_invalid_instance_pretty_output(self):
120
+ error = ValidationError("I am an error!", instance=12)
121
+ self.assertOutputs(
122
+ files=dict(
123
+ some_schema='{"does not": "matter since it is stubbed"}',
124
+ some_instance=json.dumps(error.instance),
125
+ ),
126
+ validator=fake_validator([error]),
127
+
128
+ argv=["-i", "some_instance", "--output", "pretty", "some_schema"],
129
+
130
+ exit_code=1,
131
+ stderr="""\
132
+ ===[ValidationError]===(some_instance)===
133
+
134
+ I am an error!
135
+ -----------------------------
136
+ """,
137
+ )
138
+
139
+ def test_invalid_instance_explicit_plain_output(self):
140
+ error = ValidationError("I am an error!", instance=12)
141
+ self.assertOutputs(
142
+ files=dict(
143
+ some_schema='{"does not": "matter since it is stubbed"}',
144
+ some_instance=json.dumps(error.instance),
145
+ ),
146
+ validator=fake_validator([error]),
147
+
148
+ argv=["--output", "plain", "-i", "some_instance", "some_schema"],
149
+
150
+ exit_code=1,
151
+ stderr="12: I am an error!\n",
152
+ )
153
+
154
+ def test_invalid_instance_multiple_errors(self):
155
+ instance = 12
156
+ first = ValidationError("First error", instance=instance)
157
+ second = ValidationError("Second error", instance=instance)
158
+
159
+ self.assertOutputs(
160
+ files=dict(
161
+ some_schema='{"does not": "matter since it is stubbed"}',
162
+ some_instance=json.dumps(instance),
163
+ ),
164
+ validator=fake_validator([first, second]),
165
+
166
+ argv=["-i", "some_instance", "some_schema"],
167
+
168
+ exit_code=1,
169
+ stderr="""\
170
+ 12: First error
171
+ 12: Second error
172
+ """,
173
+ )
174
+
175
+ def test_invalid_instance_multiple_errors_pretty_output(self):
176
+ instance = 12
177
+ first = ValidationError("First error", instance=instance)
178
+ second = ValidationError("Second error", instance=instance)
179
+
180
+ self.assertOutputs(
181
+ files=dict(
182
+ some_schema='{"does not": "matter since it is stubbed"}',
183
+ some_instance=json.dumps(instance),
184
+ ),
185
+ validator=fake_validator([first, second]),
186
+
187
+ argv=["-i", "some_instance", "--output", "pretty", "some_schema"],
188
+
189
+ exit_code=1,
190
+ stderr="""\
191
+ ===[ValidationError]===(some_instance)===
192
+
193
+ First error
194
+ -----------------------------
195
+ ===[ValidationError]===(some_instance)===
196
+
197
+ Second error
198
+ -----------------------------
199
+ """,
200
+ )
201
+
202
+ def test_multiple_invalid_instances(self):
203
+ first_instance = 12
204
+ first_errors = [
205
+ ValidationError("An error", instance=first_instance),
206
+ ValidationError("Another error", instance=first_instance),
207
+ ]
208
+ second_instance = "foo"
209
+ second_errors = [ValidationError("BOOM", instance=second_instance)]
210
+
211
+ self.assertOutputs(
212
+ files=dict(
213
+ some_schema='{"does not": "matter since it is stubbed"}',
214
+ some_first_instance=json.dumps(first_instance),
215
+ some_second_instance=json.dumps(second_instance),
216
+ ),
217
+ validator=fake_validator(first_errors, second_errors),
218
+
219
+ argv=[
220
+ "-i", "some_first_instance",
221
+ "-i", "some_second_instance",
222
+ "some_schema",
223
+ ],
224
+
225
+ exit_code=1,
226
+ stderr="""\
227
+ 12: An error
228
+ 12: Another error
229
+ foo: BOOM
230
+ """,
231
+ )
232
+
233
+ def test_multiple_invalid_instances_pretty_output(self):
234
+ first_instance = 12
235
+ first_errors = [
236
+ ValidationError("An error", instance=first_instance),
237
+ ValidationError("Another error", instance=first_instance),
238
+ ]
239
+ second_instance = "foo"
240
+ second_errors = [ValidationError("BOOM", instance=second_instance)]
241
+
242
+ self.assertOutputs(
243
+ files=dict(
244
+ some_schema='{"does not": "matter since it is stubbed"}',
245
+ some_first_instance=json.dumps(first_instance),
246
+ some_second_instance=json.dumps(second_instance),
247
+ ),
248
+ validator=fake_validator(first_errors, second_errors),
249
+
250
+ argv=[
251
+ "--output", "pretty",
252
+ "-i", "some_first_instance",
253
+ "-i", "some_second_instance",
254
+ "some_schema",
255
+ ],
256
+
257
+ exit_code=1,
258
+ stderr="""\
259
+ ===[ValidationError]===(some_first_instance)===
260
+
261
+ An error
262
+ -----------------------------
263
+ ===[ValidationError]===(some_first_instance)===
264
+
265
+ Another error
266
+ -----------------------------
267
+ ===[ValidationError]===(some_second_instance)===
268
+
269
+ BOOM
270
+ -----------------------------
271
+ """,
272
+ )
273
+
274
+ def test_custom_error_format(self):
275
+ first_instance = 12
276
+ first_errors = [
277
+ ValidationError("An error", instance=first_instance),
278
+ ValidationError("Another error", instance=first_instance),
279
+ ]
280
+ second_instance = "foo"
281
+ second_errors = [ValidationError("BOOM", instance=second_instance)]
282
+
283
+ self.assertOutputs(
284
+ files=dict(
285
+ some_schema='{"does not": "matter since it is stubbed"}',
286
+ some_first_instance=json.dumps(first_instance),
287
+ some_second_instance=json.dumps(second_instance),
288
+ ),
289
+ validator=fake_validator(first_errors, second_errors),
290
+
291
+ argv=[
292
+ "--error-format", ":{error.message}._-_.{error.instance}:",
293
+ "-i", "some_first_instance",
294
+ "-i", "some_second_instance",
295
+ "some_schema",
296
+ ],
297
+
298
+ exit_code=1,
299
+ stderr=":An error._-_.12::Another error._-_.12::BOOM._-_.foo:",
300
+ )
301
+
302
+ def test_invalid_schema(self):
303
+ self.assertOutputs(
304
+ files=dict(some_schema='{"type": 12}'),
305
+ argv=["some_schema"],
306
+
307
+ exit_code=1,
308
+ stderr="""\
309
+ 12: 12 is not valid under any of the given schemas
310
+ """,
311
+ )
312
+
313
+ def test_invalid_schema_pretty_output(self):
314
+ schema = {"type": 12}
315
+
316
+ with self.assertRaises(SchemaError) as e:
317
+ validate(schema=schema, instance="")
318
+ error = str(e.exception)
319
+
320
+ self.assertOutputs(
321
+ files=dict(some_schema=json.dumps(schema)),
322
+ argv=["--output", "pretty", "some_schema"],
323
+
324
+ exit_code=1,
325
+ stderr=(
326
+ "===[SchemaError]===(some_schema)===\n\n"
327
+ + str(error)
328
+ + "\n-----------------------------\n"
329
+ ),
330
+ )
331
+
332
+ def test_invalid_schema_multiple_errors(self):
333
+ self.assertOutputs(
334
+ files=dict(some_schema='{"type": 12, "items": 57}'),
335
+ argv=["some_schema"],
336
+
337
+ exit_code=1,
338
+ stderr="""\
339
+ 57: 57 is not of type 'object', 'boolean'
340
+ """,
341
+ )
342
+
343
+ def test_invalid_schema_multiple_errors_pretty_output(self):
344
+ schema = {"type": 12, "items": 57}
345
+
346
+ with self.assertRaises(SchemaError) as e:
347
+ validate(schema=schema, instance="")
348
+ error = str(e.exception)
349
+
350
+ self.assertOutputs(
351
+ files=dict(some_schema=json.dumps(schema)),
352
+ argv=["--output", "pretty", "some_schema"],
353
+
354
+ exit_code=1,
355
+ stderr=(
356
+ "===[SchemaError]===(some_schema)===\n\n"
357
+ + str(error)
358
+ + "\n-----------------------------\n"
359
+ ),
360
+ )
361
+
362
+ def test_invalid_schema_with_invalid_instance(self):
363
+ """
364
+ "Validating" an instance that's invalid under an invalid schema
365
+ just shows the schema error.
366
+ """
367
+ self.assertOutputs(
368
+ files=dict(
369
+ some_schema='{"type": 12, "minimum": 30}',
370
+ some_instance="13",
371
+ ),
372
+ argv=["-i", "some_instance", "some_schema"],
373
+
374
+ exit_code=1,
375
+ stderr="""\
376
+ 12: 12 is not valid under any of the given schemas
377
+ """,
378
+ )
379
+
380
+ def test_invalid_schema_with_invalid_instance_pretty_output(self):
381
+ instance, schema = 13, {"type": 12, "minimum": 30}
382
+
383
+ with self.assertRaises(SchemaError) as e:
384
+ validate(schema=schema, instance=instance)
385
+ error = str(e.exception)
386
+
387
+ self.assertOutputs(
388
+ files=dict(
389
+ some_schema=json.dumps(schema),
390
+ some_instance=json.dumps(instance),
391
+ ),
392
+ argv=["--output", "pretty", "-i", "some_instance", "some_schema"],
393
+
394
+ exit_code=1,
395
+ stderr=(
396
+ "===[SchemaError]===(some_schema)===\n\n"
397
+ + str(error)
398
+ + "\n-----------------------------\n"
399
+ ),
400
+ )
401
+
402
+ def test_invalid_instance_continues_with_the_rest(self):
403
+ self.assertOutputs(
404
+ files=dict(
405
+ some_schema='{"minimum": 30}',
406
+ first_instance="not valid JSON!",
407
+ second_instance="12",
408
+ ),
409
+ argv=[
410
+ "-i", "first_instance",
411
+ "-i", "second_instance",
412
+ "some_schema",
413
+ ],
414
+
415
+ exit_code=1,
416
+ stderr="""\
417
+ Failed to parse 'first_instance': {}
418
+ 12: 12 is less than the minimum of 30
419
+ """.format(_message_for("not valid JSON!")),
420
+ )
421
+
422
+ def test_custom_error_format_applies_to_schema_errors(self):
423
+ instance, schema = 13, {"type": 12, "minimum": 30}
424
+
425
+ with self.assertRaises(SchemaError):
426
+ validate(schema=schema, instance=instance)
427
+
428
+ self.assertOutputs(
429
+ files=dict(some_schema=json.dumps(schema)),
430
+
431
+ argv=[
432
+ "--error-format", ":{error.message}._-_.{error.instance}:",
433
+ "some_schema",
434
+ ],
435
+
436
+ exit_code=1,
437
+ stderr=":12 is not valid under any of the given schemas._-_.12:",
438
+ )
439
+
440
+ def test_instance_is_invalid_JSON(self):
441
+ instance = "not valid JSON!"
442
+
443
+ self.assertOutputs(
444
+ files=dict(some_schema="{}", some_instance=instance),
445
+ argv=["-i", "some_instance", "some_schema"],
446
+
447
+ exit_code=1,
448
+ stderr=f"""\
449
+ Failed to parse 'some_instance': {_message_for(instance)}
450
+ """,
451
+ )
452
+
453
+ def test_instance_is_invalid_JSON_pretty_output(self):
454
+ stdout, stderr = self.run_cli(
455
+ files=dict(
456
+ some_schema="{}",
457
+ some_instance="not valid JSON!",
458
+ ),
459
+
460
+ argv=["--output", "pretty", "-i", "some_instance", "some_schema"],
461
+
462
+ exit_code=1,
463
+ )
464
+ self.assertFalse(stdout)
465
+ self.assertIn(
466
+ "(some_instance)===\n\nTraceback (most recent call last):\n",
467
+ stderr,
468
+ )
469
+ self.assertNotIn("some_schema", stderr)
470
+
471
+ def test_instance_is_invalid_JSON_on_stdin(self):
472
+ instance = "not valid JSON!"
473
+
474
+ self.assertOutputs(
475
+ files=dict(some_schema="{}"),
476
+ stdin=StringIO(instance),
477
+
478
+ argv=["some_schema"],
479
+
480
+ exit_code=1,
481
+ stderr=f"""\
482
+ Failed to parse <stdin>: {_message_for(instance)}
483
+ """,
484
+ )
485
+
486
+ def test_instance_is_invalid_JSON_on_stdin_pretty_output(self):
487
+ stdout, stderr = self.run_cli(
488
+ files=dict(some_schema="{}"),
489
+ stdin=StringIO("not valid JSON!"),
490
+
491
+ argv=["--output", "pretty", "some_schema"],
492
+
493
+ exit_code=1,
494
+ )
495
+ self.assertFalse(stdout)
496
+ self.assertIn(
497
+ "(<stdin>)===\n\nTraceback (most recent call last):\n",
498
+ stderr,
499
+ )
500
+ self.assertNotIn("some_schema", stderr)
501
+
502
+ def test_schema_is_invalid_JSON(self):
503
+ schema = "not valid JSON!"
504
+
505
+ self.assertOutputs(
506
+ files=dict(some_schema=schema),
507
+
508
+ argv=["some_schema"],
509
+
510
+ exit_code=1,
511
+ stderr=f"""\
512
+ Failed to parse 'some_schema': {_message_for(schema)}
513
+ """,
514
+ )
515
+
516
+ def test_schema_is_invalid_JSON_pretty_output(self):
517
+ stdout, stderr = self.run_cli(
518
+ files=dict(some_schema="not valid JSON!"),
519
+
520
+ argv=["--output", "pretty", "some_schema"],
521
+
522
+ exit_code=1,
523
+ )
524
+ self.assertFalse(stdout)
525
+ self.assertIn(
526
+ "(some_schema)===\n\nTraceback (most recent call last):\n",
527
+ stderr,
528
+ )
529
+
530
+ def test_schema_and_instance_are_both_invalid_JSON(self):
531
+ """
532
+ Only the schema error is reported, as we abort immediately.
533
+ """
534
+ schema, instance = "not valid JSON!", "also not valid JSON!"
535
+ self.assertOutputs(
536
+ files=dict(some_schema=schema, some_instance=instance),
537
+
538
+ argv=["some_schema"],
539
+
540
+ exit_code=1,
541
+ stderr=f"""\
542
+ Failed to parse 'some_schema': {_message_for(schema)}
543
+ """,
544
+ )
545
+
546
+ def test_schema_and_instance_are_both_invalid_JSON_pretty_output(self):
547
+ """
548
+ Only the schema error is reported, as we abort immediately.
549
+ """
550
+ stdout, stderr = self.run_cli(
551
+ files=dict(
552
+ some_schema="not valid JSON!",
553
+ some_instance="also not valid JSON!",
554
+ ),
555
+
556
+ argv=["--output", "pretty", "-i", "some_instance", "some_schema"],
557
+
558
+ exit_code=1,
559
+ )
560
+ self.assertFalse(stdout)
561
+ self.assertIn(
562
+ "(some_schema)===\n\nTraceback (most recent call last):\n",
563
+ stderr,
564
+ )
565
+ self.assertNotIn("some_instance", stderr)
566
+
567
+ def test_instance_does_not_exist(self):
568
+ self.assertOutputs(
569
+ files=dict(some_schema="{}"),
570
+ argv=["-i", "nonexisting_instance", "some_schema"],
571
+
572
+ exit_code=1,
573
+ stderr="""\
574
+ 'nonexisting_instance' does not exist.
575
+ """,
576
+ )
577
+
578
+ def test_instance_does_not_exist_pretty_output(self):
579
+ self.assertOutputs(
580
+ files=dict(some_schema="{}"),
581
+ argv=[
582
+ "--output", "pretty",
583
+ "-i", "nonexisting_instance",
584
+ "some_schema",
585
+ ],
586
+
587
+ exit_code=1,
588
+ stderr="""\
589
+ ===[FileNotFoundError]===(nonexisting_instance)===
590
+
591
+ 'nonexisting_instance' does not exist.
592
+ -----------------------------
593
+ """,
594
+ )
595
+
596
+ def test_schema_does_not_exist(self):
597
+ self.assertOutputs(
598
+ argv=["nonexisting_schema"],
599
+
600
+ exit_code=1,
601
+ stderr="'nonexisting_schema' does not exist.\n",
602
+ )
603
+
604
+ def test_schema_does_not_exist_pretty_output(self):
605
+ self.assertOutputs(
606
+ argv=["--output", "pretty", "nonexisting_schema"],
607
+
608
+ exit_code=1,
609
+ stderr="""\
610
+ ===[FileNotFoundError]===(nonexisting_schema)===
611
+
612
+ 'nonexisting_schema' does not exist.
613
+ -----------------------------
614
+ """,
615
+ )
616
+
617
+ def test_neither_instance_nor_schema_exist(self):
618
+ self.assertOutputs(
619
+ argv=["-i", "nonexisting_instance", "nonexisting_schema"],
620
+
621
+ exit_code=1,
622
+ stderr="'nonexisting_schema' does not exist.\n",
623
+ )
624
+
625
+ def test_neither_instance_nor_schema_exist_pretty_output(self):
626
+ self.assertOutputs(
627
+ argv=[
628
+ "--output", "pretty",
629
+ "-i", "nonexisting_instance",
630
+ "nonexisting_schema",
631
+ ],
632
+
633
+ exit_code=1,
634
+ stderr="""\
635
+ ===[FileNotFoundError]===(nonexisting_schema)===
636
+
637
+ 'nonexisting_schema' does not exist.
638
+ -----------------------------
639
+ """,
640
+ )
641
+
642
+ def test_successful_validation(self):
643
+ self.assertOutputs(
644
+ files=dict(some_schema="{}", some_instance="{}"),
645
+ argv=["-i", "some_instance", "some_schema"],
646
+ stdout="",
647
+ stderr="",
648
+ )
649
+
650
+ def test_successful_validation_pretty_output(self):
651
+ self.assertOutputs(
652
+ files=dict(some_schema="{}", some_instance="{}"),
653
+ argv=["--output", "pretty", "-i", "some_instance", "some_schema"],
654
+ stdout="===[SUCCESS]===(some_instance)===\n",
655
+ stderr="",
656
+ )
657
+
658
+ def test_successful_validation_of_stdin(self):
659
+ self.assertOutputs(
660
+ files=dict(some_schema="{}"),
661
+ stdin=StringIO("{}"),
662
+ argv=["some_schema"],
663
+ stdout="",
664
+ stderr="",
665
+ )
666
+
667
+ def test_successful_validation_of_stdin_pretty_output(self):
668
+ self.assertOutputs(
669
+ files=dict(some_schema="{}"),
670
+ stdin=StringIO("{}"),
671
+ argv=["--output", "pretty", "some_schema"],
672
+ stdout="===[SUCCESS]===(<stdin>)===\n",
673
+ stderr="",
674
+ )
675
+
676
+ def test_successful_validation_of_just_the_schema(self):
677
+ self.assertOutputs(
678
+ files=dict(some_schema="{}", some_instance="{}"),
679
+ argv=["-i", "some_instance", "some_schema"],
680
+ stdout="",
681
+ stderr="",
682
+ )
683
+
684
+ def test_successful_validation_of_just_the_schema_pretty_output(self):
685
+ self.assertOutputs(
686
+ files=dict(some_schema="{}", some_instance="{}"),
687
+ argv=["--output", "pretty", "-i", "some_instance", "some_schema"],
688
+ stdout="===[SUCCESS]===(some_instance)===\n",
689
+ stderr="",
690
+ )
691
+
692
+ def test_successful_validation_via_explicit_base_uri(self):
693
+ ref_schema_file = tempfile.NamedTemporaryFile(delete=False)
694
+ ref_schema_file.close()
695
+ self.addCleanup(os.remove, ref_schema_file.name)
696
+
697
+ ref_path = Path(ref_schema_file.name)
698
+ ref_path.write_text('{"definitions": {"num": {"type": "integer"}}}')
699
+
700
+ schema = f'{{"$ref": "{ref_path.name}#/definitions/num"}}'
701
+
702
+ self.assertOutputs(
703
+ files=dict(some_schema=schema, some_instance="1"),
704
+ argv=[
705
+ "-i", "some_instance",
706
+ "--base-uri", ref_path.parent.as_uri() + "/",
707
+ "some_schema",
708
+ ],
709
+ stdout="",
710
+ stderr="",
711
+ )
712
+
713
+ def test_unsuccessful_validation_via_explicit_base_uri(self):
714
+ ref_schema_file = tempfile.NamedTemporaryFile(delete=False)
715
+ ref_schema_file.close()
716
+ self.addCleanup(os.remove, ref_schema_file.name)
717
+
718
+ ref_path = Path(ref_schema_file.name)
719
+ ref_path.write_text('{"definitions": {"num": {"type": "integer"}}}')
720
+
721
+ schema = f'{{"$ref": "{ref_path.name}#/definitions/num"}}'
722
+
723
+ self.assertOutputs(
724
+ files=dict(some_schema=schema, some_instance='"1"'),
725
+ argv=[
726
+ "-i", "some_instance",
727
+ "--base-uri", ref_path.parent.as_uri() + "/",
728
+ "some_schema",
729
+ ],
730
+ exit_code=1,
731
+ stdout="",
732
+ stderr="1: '1' is not of type 'integer'\n",
733
+ )
734
+
735
+ def test_nonexistent_file_with_explicit_base_uri(self):
736
+ schema = '{"$ref": "someNonexistentFile.json#definitions/num"}'
737
+ instance = "1"
738
+
739
+ with self.assertRaises(_RefResolutionError) as e:
740
+ self.assertOutputs(
741
+ files=dict(
742
+ some_schema=schema,
743
+ some_instance=instance,
744
+ ),
745
+ argv=[
746
+ "-i", "some_instance",
747
+ "--base-uri", Path.cwd().as_uri(),
748
+ "some_schema",
749
+ ],
750
+ )
751
+ error = str(e.exception)
752
+ self.assertIn(f"{os.sep}someNonexistentFile.json'", error)
753
+
754
+ def test_invalid_explicit_base_uri(self):
755
+ schema = '{"$ref": "foo.json#definitions/num"}'
756
+ instance = "1"
757
+
758
+ with self.assertRaises(_RefResolutionError) as e:
759
+ self.assertOutputs(
760
+ files=dict(
761
+ some_schema=schema,
762
+ some_instance=instance,
763
+ ),
764
+ argv=[
765
+ "-i", "some_instance",
766
+ "--base-uri", "not@UR1",
767
+ "some_schema",
768
+ ],
769
+ )
770
+ error = str(e.exception)
771
+ self.assertEqual(
772
+ error, "unknown url type: 'foo.json'",
773
+ )
774
+
775
+ def test_it_validates_using_the_latest_validator_when_unspecified(self):
776
+ # There isn't a better way now I can think of to ensure that the
777
+ # latest version was used, given that the call to validator_for
778
+ # is hidden inside the CLI, so guard that that's the case, and
779
+ # this test will have to be updated when versions change until
780
+ # we can think of a better way to ensure this behavior.
781
+ self.assertIs(Draft202012Validator, _LATEST_VERSION)
782
+
783
+ self.assertOutputs(
784
+ files=dict(some_schema='{"const": "check"}', some_instance='"a"'),
785
+ argv=["-i", "some_instance", "some_schema"],
786
+ exit_code=1,
787
+ stdout="",
788
+ stderr="a: 'check' was expected\n",
789
+ )
790
+
791
+ def test_it_validates_using_draft7_when_specified(self):
792
+ """
793
+ Specifically, `const` validation applies for Draft 7.
794
+ """
795
+ schema = """
796
+ {
797
+ "$schema": "http://json-schema.org/draft-07/schema#",
798
+ "const": "check"
799
+ }
800
+ """
801
+ instance = '"foo"'
802
+ self.assertOutputs(
803
+ files=dict(some_schema=schema, some_instance=instance),
804
+ argv=["-i", "some_instance", "some_schema"],
805
+ exit_code=1,
806
+ stdout="",
807
+ stderr="foo: 'check' was expected\n",
808
+ )
809
+
810
+ def test_it_validates_using_draft4_when_specified(self):
811
+ """
812
+ Specifically, `const` validation *does not* apply for Draft 4.
813
+ """
814
+ schema = """
815
+ {
816
+ "$schema": "http://json-schema.org/draft-04/schema#",
817
+ "const": "check"
818
+ }
819
+ """
820
+ instance = '"foo"'
821
+ self.assertOutputs(
822
+ files=dict(some_schema=schema, some_instance=instance),
823
+ argv=["-i", "some_instance", "some_schema"],
824
+ stdout="",
825
+ stderr="",
826
+ )
827
+
828
+
829
+ class TestParser(TestCase):
830
+
831
+ FakeValidator = fake_validator()
832
+
833
+ def test_find_validator_by_fully_qualified_object_name(self):
834
+ arguments = cli.parse_args(
835
+ [
836
+ "--validator",
837
+ "jsonschema.tests.test_cli.TestParser.FakeValidator",
838
+ "--instance", "mem://some/instance",
839
+ "mem://some/schema",
840
+ ],
841
+ )
842
+ self.assertIs(arguments["validator"], self.FakeValidator)
843
+
844
+ def test_find_validator_in_jsonschema(self):
845
+ arguments = cli.parse_args(
846
+ [
847
+ "--validator", "Draft4Validator",
848
+ "--instance", "mem://some/instance",
849
+ "mem://some/schema",
850
+ ],
851
+ )
852
+ self.assertIs(arguments["validator"], Draft4Validator)
853
+
854
+ def cli_output_for(self, *argv):
855
+ stdout, stderr = StringIO(), StringIO()
856
+ with redirect_stdout(stdout), redirect_stderr(stderr):
857
+ with self.assertRaises(SystemExit):
858
+ cli.parse_args(argv)
859
+ return stdout.getvalue(), stderr.getvalue()
860
+
861
+ def test_unknown_output(self):
862
+ stdout, stderr = self.cli_output_for(
863
+ "--output", "foo",
864
+ "mem://some/schema",
865
+ )
866
+ self.assertIn("invalid choice: 'foo'", stderr)
867
+ self.assertFalse(stdout)
868
+
869
+ def test_useless_error_format(self):
870
+ stdout, stderr = self.cli_output_for(
871
+ "--output", "pretty",
872
+ "--error-format", "foo",
873
+ "mem://some/schema",
874
+ )
875
+ self.assertIn(
876
+ "--error-format can only be used with --output plain",
877
+ stderr,
878
+ )
879
+ self.assertFalse(stdout)
880
+
881
+
882
+ class TestCLIIntegration(TestCase):
883
+ def test_license(self):
884
+ output = subprocess.check_output(
885
+ [sys.executable, "-m", "pip", "show", "jsonschema"],
886
+ stderr=subprocess.STDOUT,
887
+ )
888
+ self.assertIn(b"License: MIT", output)
889
+
890
+ def test_version(self):
891
+ version = subprocess.check_output(
892
+ [sys.executable, "-W", "ignore", "-m", "jsonschema", "--version"],
893
+ stderr=subprocess.STDOUT,
894
+ )
895
+ version = version.decode("utf-8").strip()
896
+ self.assertEqual(version, metadata.version("jsonschema"))
897
+
898
+ def test_no_arguments_shows_usage_notes(self):
899
+ output = subprocess.check_output(
900
+ [sys.executable, "-m", "jsonschema"],
901
+ stderr=subprocess.STDOUT,
902
+ )
903
+ output_for_help = subprocess.check_output(
904
+ [sys.executable, "-m", "jsonschema", "--help"],
905
+ stderr=subprocess.STDOUT,
906
+ )
907
+ self.assertEqual(output, output_for_help)
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/test_deprecations.py ADDED
@@ -0,0 +1,431 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from contextlib import contextmanager
2
+ from io import BytesIO
3
+ from unittest import TestCase, mock
4
+ import importlib.metadata
5
+ import json
6
+ import subprocess
7
+ import sys
8
+ import urllib.request
9
+
10
+ import referencing.exceptions
11
+
12
+ from jsonschema import FormatChecker, exceptions, protocols, validators
13
+
14
+
15
+ class TestDeprecations(TestCase):
16
+ def test_version(self):
17
+ """
18
+ As of v4.0.0, __version__ is deprecated in favor of importlib.metadata.
19
+ """
20
+
21
+ message = "Accessing jsonschema.__version__ is deprecated"
22
+ with self.assertWarnsRegex(DeprecationWarning, message) as w:
23
+ from jsonschema import __version__
24
+
25
+ self.assertEqual(__version__, importlib.metadata.version("jsonschema"))
26
+ self.assertEqual(w.filename, __file__)
27
+
28
+ def test_validators_ErrorTree(self):
29
+ """
30
+ As of v4.0.0, importing ErrorTree from jsonschema.validators is
31
+ deprecated in favor of doing so from jsonschema.exceptions.
32
+ """
33
+
34
+ message = "Importing ErrorTree from jsonschema.validators is "
35
+ with self.assertWarnsRegex(DeprecationWarning, message) as w:
36
+ from jsonschema.validators import ErrorTree
37
+
38
+ self.assertEqual(ErrorTree, exceptions.ErrorTree)
39
+ self.assertEqual(w.filename, __file__)
40
+
41
+ def test_import_ErrorTree(self):
42
+ """
43
+ As of v4.18.0, importing ErrorTree from the package root is
44
+ deprecated in favor of doing so from jsonschema.exceptions.
45
+ """
46
+
47
+ message = "Importing ErrorTree directly from the jsonschema package "
48
+ with self.assertWarnsRegex(DeprecationWarning, message) as w:
49
+ from jsonschema import ErrorTree
50
+
51
+ self.assertEqual(ErrorTree, exceptions.ErrorTree)
52
+ self.assertEqual(w.filename, __file__)
53
+
54
+ def test_ErrorTree_setitem(self):
55
+ """
56
+ As of v4.20.0, setting items on an ErrorTree is deprecated.
57
+ """
58
+
59
+ e = exceptions.ValidationError("some error", path=["foo"])
60
+ tree = exceptions.ErrorTree()
61
+ subtree = exceptions.ErrorTree(errors=[e])
62
+
63
+ message = "ErrorTree.__setitem__ is "
64
+ with self.assertWarnsRegex(DeprecationWarning, message) as w:
65
+ tree["foo"] = subtree
66
+
67
+ self.assertEqual(tree["foo"], subtree)
68
+ self.assertEqual(w.filename, __file__)
69
+
70
+ def test_import_FormatError(self):
71
+ """
72
+ As of v4.18.0, importing FormatError from the package root is
73
+ deprecated in favor of doing so from jsonschema.exceptions.
74
+ """
75
+
76
+ message = "Importing FormatError directly from the jsonschema package "
77
+ with self.assertWarnsRegex(DeprecationWarning, message) as w:
78
+ from jsonschema import FormatError
79
+
80
+ self.assertEqual(FormatError, exceptions.FormatError)
81
+ self.assertEqual(w.filename, __file__)
82
+
83
+ def test_import_Validator(self):
84
+ """
85
+ As of v4.19.0, importing Validator from the package root is
86
+ deprecated in favor of doing so from jsonschema.protocols.
87
+ """
88
+
89
+ message = "Importing Validator directly from the jsonschema package "
90
+ with self.assertWarnsRegex(DeprecationWarning, message) as w:
91
+ from jsonschema import Validator
92
+
93
+ self.assertEqual(Validator, protocols.Validator)
94
+ self.assertEqual(w.filename, __file__)
95
+
96
+ def test_validators_validators(self):
97
+ """
98
+ As of v4.0.0, accessing jsonschema.validators.validators is
99
+ deprecated.
100
+ """
101
+
102
+ message = "Accessing jsonschema.validators.validators is deprecated"
103
+ with self.assertWarnsRegex(DeprecationWarning, message) as w:
104
+ value = validators.validators
105
+
106
+ self.assertEqual(value, validators._VALIDATORS)
107
+ self.assertEqual(w.filename, __file__)
108
+
109
+ def test_validators_meta_schemas(self):
110
+ """
111
+ As of v4.0.0, accessing jsonschema.validators.meta_schemas is
112
+ deprecated.
113
+ """
114
+
115
+ message = "Accessing jsonschema.validators.meta_schemas is deprecated"
116
+ with self.assertWarnsRegex(DeprecationWarning, message) as w:
117
+ value = validators.meta_schemas
118
+
119
+ self.assertEqual(value, validators._META_SCHEMAS)
120
+ self.assertEqual(w.filename, __file__)
121
+
122
+ def test_RefResolver_in_scope(self):
123
+ """
124
+ As of v4.0.0, RefResolver.in_scope is deprecated.
125
+ """
126
+
127
+ resolver = validators._RefResolver.from_schema({})
128
+ message = "jsonschema.RefResolver.in_scope is deprecated "
129
+ with self.assertWarnsRegex(DeprecationWarning, message) as w:
130
+ with resolver.in_scope("foo"):
131
+ pass
132
+
133
+ self.assertEqual(w.filename, __file__)
134
+
135
+ def test_Validator_is_valid_two_arguments(self):
136
+ """
137
+ As of v4.0.0, calling is_valid with two arguments (to provide a
138
+ different schema) is deprecated.
139
+ """
140
+
141
+ validator = validators.Draft7Validator({})
142
+ message = "Passing a schema to Validator.is_valid is deprecated "
143
+ with self.assertWarnsRegex(DeprecationWarning, message) as w:
144
+ result = validator.is_valid("foo", {"type": "number"})
145
+
146
+ self.assertFalse(result)
147
+ self.assertEqual(w.filename, __file__)
148
+
149
+ def test_Validator_iter_errors_two_arguments(self):
150
+ """
151
+ As of v4.0.0, calling iter_errors with two arguments (to provide a
152
+ different schema) is deprecated.
153
+ """
154
+
155
+ validator = validators.Draft7Validator({})
156
+ message = "Passing a schema to Validator.iter_errors is deprecated "
157
+ with self.assertWarnsRegex(DeprecationWarning, message) as w:
158
+ error, = validator.iter_errors("foo", {"type": "number"})
159
+
160
+ self.assertEqual(error.validator, "type")
161
+ self.assertEqual(w.filename, __file__)
162
+
163
+ def test_Validator_resolver(self):
164
+ """
165
+ As of v4.18.0, accessing Validator.resolver is deprecated.
166
+ """
167
+
168
+ validator = validators.Draft7Validator({})
169
+ message = "Accessing Draft7Validator.resolver is "
170
+ with self.assertWarnsRegex(DeprecationWarning, message) as w:
171
+ self.assertIsInstance(validator.resolver, validators._RefResolver)
172
+
173
+ self.assertEqual(w.filename, __file__)
174
+
175
+ def test_RefResolver(self):
176
+ """
177
+ As of v4.18.0, RefResolver is fully deprecated.
178
+ """
179
+
180
+ message = "jsonschema.RefResolver is deprecated"
181
+ with self.assertWarnsRegex(DeprecationWarning, message) as w:
182
+ from jsonschema import RefResolver
183
+ self.assertEqual(w.filename, __file__)
184
+
185
+ with self.assertWarnsRegex(DeprecationWarning, message) as w:
186
+ from jsonschema.validators import RefResolver # noqa: F401, F811
187
+ self.assertEqual(w.filename, __file__)
188
+
189
+ def test_RefResolutionError(self):
190
+ """
191
+ As of v4.18.0, RefResolutionError is deprecated in favor of directly
192
+ catching errors from the referencing library.
193
+ """
194
+
195
+ message = "jsonschema.exceptions.RefResolutionError is deprecated"
196
+ with self.assertWarnsRegex(DeprecationWarning, message) as w:
197
+ from jsonschema import RefResolutionError
198
+
199
+ self.assertEqual(RefResolutionError, exceptions._RefResolutionError)
200
+ self.assertEqual(w.filename, __file__)
201
+
202
+ with self.assertWarnsRegex(DeprecationWarning, message) as w:
203
+ from jsonschema.exceptions import RefResolutionError
204
+
205
+ self.assertEqual(RefResolutionError, exceptions._RefResolutionError)
206
+ self.assertEqual(w.filename, __file__)
207
+
208
+ def test_catching_Unresolvable_directly(self):
209
+ """
210
+ This behavior is the intended behavior (i.e. it's not deprecated), but
211
+ given we do "tricksy" things in the iterim to wrap exceptions in a
212
+ multiple inheritance subclass, we need to be extra sure it works and
213
+ stays working.
214
+ """
215
+ validator = validators.Draft202012Validator({"$ref": "urn:nothing"})
216
+
217
+ with self.assertRaises(referencing.exceptions.Unresolvable) as e:
218
+ validator.validate(12)
219
+
220
+ expected = referencing.exceptions.Unresolvable(ref="urn:nothing")
221
+ self.assertEqual(
222
+ (e.exception, str(e.exception)),
223
+ (expected, "Unresolvable: urn:nothing")
224
+ )
225
+
226
+ def test_catching_Unresolvable_via_RefResolutionError(self):
227
+ """
228
+ Until RefResolutionError is removed, it is still possible to catch
229
+ exceptions from reference resolution using it, even though they may
230
+ have been raised by referencing.
231
+ """
232
+ with self.assertWarns(DeprecationWarning):
233
+ from jsonschema import RefResolutionError
234
+
235
+ validator = validators.Draft202012Validator({"$ref": "urn:nothing"})
236
+
237
+ with self.assertRaises(referencing.exceptions.Unresolvable) as u:
238
+ validator.validate(12)
239
+
240
+ with self.assertRaises(RefResolutionError) as e:
241
+ validator.validate(12)
242
+
243
+ self.assertEqual(
244
+ (e.exception, str(e.exception)),
245
+ (u.exception, "Unresolvable: urn:nothing")
246
+ )
247
+
248
+ def test_WrappedReferencingError_hashability(self):
249
+ """
250
+ Ensure the wrapped referencing errors are hashable when possible.
251
+ """
252
+ with self.assertWarns(DeprecationWarning):
253
+ from jsonschema import RefResolutionError
254
+
255
+ validator = validators.Draft202012Validator({"$ref": "urn:nothing"})
256
+
257
+ with self.assertRaises(referencing.exceptions.Unresolvable) as u:
258
+ validator.validate(12)
259
+
260
+ with self.assertRaises(RefResolutionError) as e:
261
+ validator.validate(12)
262
+
263
+ self.assertIn(e.exception, {u.exception})
264
+ self.assertIn(u.exception, {e.exception})
265
+
266
+ def test_Validator_subclassing(self):
267
+ """
268
+ As of v4.12.0, subclassing a validator class produces an explicit
269
+ deprecation warning.
270
+
271
+ This was never intended to be public API (and some comments over the
272
+ years in issues said so, but obviously that's not a great way to make
273
+ sure it's followed).
274
+
275
+ A future version will explicitly raise an error.
276
+ """
277
+
278
+ message = "Subclassing validator classes is "
279
+ with self.assertWarnsRegex(DeprecationWarning, message) as w:
280
+ class Subclass(validators.Draft202012Validator):
281
+ pass
282
+
283
+ self.assertEqual(w.filename, __file__)
284
+
285
+ with self.assertWarnsRegex(DeprecationWarning, message) as w:
286
+ class AnotherSubclass(validators.create(meta_schema={})):
287
+ pass
288
+
289
+ def test_FormatChecker_cls_checks(self):
290
+ """
291
+ As of v4.14.0, FormatChecker.cls_checks is deprecated without
292
+ replacement.
293
+ """
294
+
295
+ self.addCleanup(FormatChecker.checkers.pop, "boom", None)
296
+
297
+ message = "FormatChecker.cls_checks "
298
+ with self.assertWarnsRegex(DeprecationWarning, message) as w:
299
+ FormatChecker.cls_checks("boom")
300
+
301
+ self.assertEqual(w.filename, __file__)
302
+
303
+ def test_draftN_format_checker(self):
304
+ """
305
+ As of v4.16.0, accessing jsonschema.draftn_format_checker is deprecated
306
+ in favor of Validator.FORMAT_CHECKER.
307
+ """
308
+
309
+ message = "Accessing jsonschema.draft202012_format_checker is "
310
+ with self.assertWarnsRegex(DeprecationWarning, message) as w:
311
+ from jsonschema import draft202012_format_checker
312
+
313
+ self.assertIs(
314
+ draft202012_format_checker,
315
+ validators.Draft202012Validator.FORMAT_CHECKER,
316
+ )
317
+ self.assertEqual(w.filename, __file__)
318
+
319
+ message = "Accessing jsonschema.draft201909_format_checker is "
320
+ with self.assertWarnsRegex(DeprecationWarning, message) as w:
321
+ from jsonschema import draft201909_format_checker
322
+
323
+ self.assertIs(
324
+ draft201909_format_checker,
325
+ validators.Draft201909Validator.FORMAT_CHECKER,
326
+ )
327
+ self.assertEqual(w.filename, __file__)
328
+
329
+ message = "Accessing jsonschema.draft7_format_checker is "
330
+ with self.assertWarnsRegex(DeprecationWarning, message) as w:
331
+ from jsonschema import draft7_format_checker
332
+
333
+ self.assertIs(
334
+ draft7_format_checker,
335
+ validators.Draft7Validator.FORMAT_CHECKER,
336
+ )
337
+ self.assertEqual(w.filename, __file__)
338
+
339
+ message = "Accessing jsonschema.draft6_format_checker is "
340
+ with self.assertWarnsRegex(DeprecationWarning, message) as w:
341
+ from jsonschema import draft6_format_checker
342
+
343
+ self.assertIs(
344
+ draft6_format_checker,
345
+ validators.Draft6Validator.FORMAT_CHECKER,
346
+ )
347
+ self.assertEqual(w.filename, __file__)
348
+
349
+ message = "Accessing jsonschema.draft4_format_checker is "
350
+ with self.assertWarnsRegex(DeprecationWarning, message) as w:
351
+ from jsonschema import draft4_format_checker
352
+
353
+ self.assertIs(
354
+ draft4_format_checker,
355
+ validators.Draft4Validator.FORMAT_CHECKER,
356
+ )
357
+ self.assertEqual(w.filename, __file__)
358
+
359
+ message = "Accessing jsonschema.draft3_format_checker is "
360
+ with self.assertWarnsRegex(DeprecationWarning, message) as w:
361
+ from jsonschema import draft3_format_checker
362
+
363
+ self.assertIs(
364
+ draft3_format_checker,
365
+ validators.Draft3Validator.FORMAT_CHECKER,
366
+ )
367
+ self.assertEqual(w.filename, __file__)
368
+
369
+ with self.assertRaises(ImportError):
370
+ from jsonschema import draft1234_format_checker # noqa
371
+
372
+ def test_import_cli(self):
373
+ """
374
+ As of v4.17.0, importing jsonschema.cli is deprecated.
375
+ """
376
+
377
+ message = "The jsonschema CLI is deprecated and will be removed "
378
+ with self.assertWarnsRegex(DeprecationWarning, message) as w:
379
+ import jsonschema.cli
380
+ importlib.reload(jsonschema.cli)
381
+
382
+ self.assertEqual(w.filename, importlib.__file__)
383
+
384
+ def test_cli(self):
385
+ """
386
+ As of v4.17.0, the jsonschema CLI is deprecated.
387
+ """
388
+
389
+ process = subprocess.run(
390
+ [sys.executable, "-m", "jsonschema"],
391
+ capture_output=True,
392
+ )
393
+ self.assertIn(b"The jsonschema CLI is deprecated ", process.stderr)
394
+
395
+ def test_automatic_remote_retrieval(self):
396
+ """
397
+ Automatic retrieval of remote references is deprecated as of v4.18.0.
398
+ """
399
+ ref = "http://bar#/$defs/baz"
400
+ schema = {"$defs": {"baz": {"type": "integer"}}}
401
+
402
+ if "requests" in sys.modules: # pragma: no cover
403
+ self.addCleanup(
404
+ sys.modules.__setitem__, "requests", sys.modules["requests"],
405
+ )
406
+ sys.modules["requests"] = None
407
+
408
+ @contextmanager
409
+ def fake_urlopen(request):
410
+ self.assertIsInstance(request, urllib.request.Request)
411
+ self.assertEqual(request.full_url, "http://bar")
412
+
413
+ # Ha ha urllib.request.Request "normalizes" header names and
414
+ # Request.get_header does not also normalize them...
415
+ (header, value), = request.header_items()
416
+ self.assertEqual(header.lower(), "user-agent")
417
+ self.assertEqual(
418
+ value, "python-jsonschema (deprecated $ref resolution)",
419
+ )
420
+ yield BytesIO(json.dumps(schema).encode("utf8"))
421
+
422
+ validator = validators.Draft202012Validator({"$ref": ref})
423
+
424
+ message = "Automatically retrieving remote references "
425
+ patch = mock.patch.object(urllib.request, "urlopen", new=fake_urlopen)
426
+
427
+ with patch, self.assertWarnsRegex(DeprecationWarning, message):
428
+ self.assertEqual(
429
+ (validator.is_valid({}), validator.is_valid(37)),
430
+ (False, True),
431
+ )
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/test_exceptions.py ADDED
@@ -0,0 +1,617 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from unittest import TestCase
2
+ import textwrap
3
+
4
+ from jsonschema import exceptions
5
+ from jsonschema.validators import _LATEST_VERSION
6
+
7
+
8
+ class TestBestMatch(TestCase):
9
+ def best_match_of(self, instance, schema):
10
+ errors = list(_LATEST_VERSION(schema).iter_errors(instance))
11
+ best = exceptions.best_match(iter(errors))
12
+ reversed_best = exceptions.best_match(reversed(errors))
13
+ self.assertEqual(
14
+ best._contents(),
15
+ reversed_best._contents(),
16
+ f"No consistent best match!\nGot: {best}\n\nThen: {reversed_best}",
17
+ )
18
+ return best
19
+
20
+ def test_shallower_errors_are_better_matches(self):
21
+ schema = {
22
+ "properties": {
23
+ "foo": {
24
+ "minProperties": 2,
25
+ "properties": {"bar": {"type": "object"}},
26
+ },
27
+ },
28
+ }
29
+ best = self.best_match_of(instance={"foo": {"bar": []}}, schema=schema)
30
+ self.assertEqual(best.validator, "minProperties")
31
+
32
+ def test_oneOf_and_anyOf_are_weak_matches(self):
33
+ """
34
+ A property you *must* match is probably better than one you have to
35
+ match a part of.
36
+ """
37
+
38
+ schema = {
39
+ "minProperties": 2,
40
+ "anyOf": [{"type": "string"}, {"type": "number"}],
41
+ "oneOf": [{"type": "string"}, {"type": "number"}],
42
+ }
43
+ best = self.best_match_of(instance={}, schema=schema)
44
+ self.assertEqual(best.validator, "minProperties")
45
+
46
+ def test_if_the_most_relevant_error_is_anyOf_it_is_traversed(self):
47
+ """
48
+ If the most relevant error is an anyOf, then we traverse its context
49
+ and select the otherwise *least* relevant error, since in this case
50
+ that means the most specific, deep, error inside the instance.
51
+
52
+ I.e. since only one of the schemas must match, we look for the most
53
+ relevant one.
54
+ """
55
+
56
+ schema = {
57
+ "properties": {
58
+ "foo": {
59
+ "anyOf": [
60
+ {"type": "string"},
61
+ {"properties": {"bar": {"type": "array"}}},
62
+ ],
63
+ },
64
+ },
65
+ }
66
+ best = self.best_match_of(instance={"foo": {"bar": 12}}, schema=schema)
67
+ self.assertEqual(best.validator_value, "array")
68
+
69
+ def test_no_anyOf_traversal_for_equally_relevant_errors(self):
70
+ """
71
+ We don't traverse into an anyOf (as above) if all of its context errors
72
+ seem to be equally "wrong" against the instance.
73
+ """
74
+
75
+ schema = {
76
+ "anyOf": [
77
+ {"type": "string"},
78
+ {"type": "integer"},
79
+ {"type": "object"},
80
+ ],
81
+ }
82
+ best = self.best_match_of(instance=[], schema=schema)
83
+ self.assertEqual(best.validator, "anyOf")
84
+
85
+ def test_anyOf_traversal_for_single_equally_relevant_error(self):
86
+ """
87
+ We *do* traverse anyOf with a single nested error, even though it is
88
+ vacuously equally relevant to itself.
89
+ """
90
+
91
+ schema = {
92
+ "anyOf": [
93
+ {"type": "string"},
94
+ ],
95
+ }
96
+ best = self.best_match_of(instance=[], schema=schema)
97
+ self.assertEqual(best.validator, "type")
98
+
99
+ def test_if_the_most_relevant_error_is_oneOf_it_is_traversed(self):
100
+ """
101
+ If the most relevant error is an oneOf, then we traverse its context
102
+ and select the otherwise *least* relevant error, since in this case
103
+ that means the most specific, deep, error inside the instance.
104
+
105
+ I.e. since only one of the schemas must match, we look for the most
106
+ relevant one.
107
+ """
108
+
109
+ schema = {
110
+ "properties": {
111
+ "foo": {
112
+ "oneOf": [
113
+ {"type": "string"},
114
+ {"properties": {"bar": {"type": "array"}}},
115
+ ],
116
+ },
117
+ },
118
+ }
119
+ best = self.best_match_of(instance={"foo": {"bar": 12}}, schema=schema)
120
+ self.assertEqual(best.validator_value, "array")
121
+
122
+ def test_no_oneOf_traversal_for_equally_relevant_errors(self):
123
+ """
124
+ We don't traverse into an oneOf (as above) if all of its context errors
125
+ seem to be equally "wrong" against the instance.
126
+ """
127
+
128
+ schema = {
129
+ "oneOf": [
130
+ {"type": "string"},
131
+ {"type": "integer"},
132
+ {"type": "object"},
133
+ ],
134
+ }
135
+ best = self.best_match_of(instance=[], schema=schema)
136
+ self.assertEqual(best.validator, "oneOf")
137
+
138
+ def test_oneOf_traversal_for_single_equally_relevant_error(self):
139
+ """
140
+ We *do* traverse oneOf with a single nested error, even though it is
141
+ vacuously equally relevant to itself.
142
+ """
143
+
144
+ schema = {
145
+ "oneOf": [
146
+ {"type": "string"},
147
+ ],
148
+ }
149
+ best = self.best_match_of(instance=[], schema=schema)
150
+ self.assertEqual(best.validator, "type")
151
+
152
+ def test_if_the_most_relevant_error_is_allOf_it_is_traversed(self):
153
+ """
154
+ Now, if the error is allOf, we traverse but select the *most* relevant
155
+ error from the context, because all schemas here must match anyways.
156
+ """
157
+
158
+ schema = {
159
+ "properties": {
160
+ "foo": {
161
+ "allOf": [
162
+ {"type": "string"},
163
+ {"properties": {"bar": {"type": "array"}}},
164
+ ],
165
+ },
166
+ },
167
+ }
168
+ best = self.best_match_of(instance={"foo": {"bar": 12}}, schema=schema)
169
+ self.assertEqual(best.validator_value, "string")
170
+
171
+ def test_nested_context_for_oneOf(self):
172
+ """
173
+ We traverse into nested contexts (a oneOf containing an error in a
174
+ nested oneOf here).
175
+ """
176
+
177
+ schema = {
178
+ "properties": {
179
+ "foo": {
180
+ "oneOf": [
181
+ {"type": "string"},
182
+ {
183
+ "oneOf": [
184
+ {"type": "string"},
185
+ {
186
+ "properties": {
187
+ "bar": {"type": "array"},
188
+ },
189
+ },
190
+ ],
191
+ },
192
+ ],
193
+ },
194
+ },
195
+ }
196
+ best = self.best_match_of(instance={"foo": {"bar": 12}}, schema=schema)
197
+ self.assertEqual(best.validator_value, "array")
198
+
199
+ def test_it_prioritizes_matching_types(self):
200
+ schema = {
201
+ "properties": {
202
+ "foo": {
203
+ "anyOf": [
204
+ {"type": "array", "minItems": 2},
205
+ {"type": "string", "minLength": 10},
206
+ ],
207
+ },
208
+ },
209
+ }
210
+ best = self.best_match_of(instance={"foo": "bar"}, schema=schema)
211
+ self.assertEqual(best.validator, "minLength")
212
+
213
+ reordered = {
214
+ "properties": {
215
+ "foo": {
216
+ "anyOf": [
217
+ {"type": "string", "minLength": 10},
218
+ {"type": "array", "minItems": 2},
219
+ ],
220
+ },
221
+ },
222
+ }
223
+ best = self.best_match_of(instance={"foo": "bar"}, schema=reordered)
224
+ self.assertEqual(best.validator, "minLength")
225
+
226
+ def test_it_prioritizes_matching_union_types(self):
227
+ schema = {
228
+ "properties": {
229
+ "foo": {
230
+ "anyOf": [
231
+ {"type": ["array", "object"], "minItems": 2},
232
+ {"type": ["integer", "string"], "minLength": 10},
233
+ ],
234
+ },
235
+ },
236
+ }
237
+ best = self.best_match_of(instance={"foo": "bar"}, schema=schema)
238
+ self.assertEqual(best.validator, "minLength")
239
+
240
+ reordered = {
241
+ "properties": {
242
+ "foo": {
243
+ "anyOf": [
244
+ {"type": "string", "minLength": 10},
245
+ {"type": "array", "minItems": 2},
246
+ ],
247
+ },
248
+ },
249
+ }
250
+ best = self.best_match_of(instance={"foo": "bar"}, schema=reordered)
251
+ self.assertEqual(best.validator, "minLength")
252
+
253
+ def test_boolean_schemas(self):
254
+ schema = {"properties": {"foo": False}}
255
+ best = self.best_match_of(instance={"foo": "bar"}, schema=schema)
256
+ self.assertIsNone(best.validator)
257
+
258
+ def test_one_error(self):
259
+ validator = _LATEST_VERSION({"minProperties": 2})
260
+ error, = validator.iter_errors({})
261
+ self.assertEqual(
262
+ exceptions.best_match(validator.iter_errors({})).validator,
263
+ "minProperties",
264
+ )
265
+
266
+ def test_no_errors(self):
267
+ validator = _LATEST_VERSION({})
268
+ self.assertIsNone(exceptions.best_match(validator.iter_errors({})))
269
+
270
+
271
+ class TestByRelevance(TestCase):
272
+ def test_short_paths_are_better_matches(self):
273
+ shallow = exceptions.ValidationError("Oh no!", path=["baz"])
274
+ deep = exceptions.ValidationError("Oh yes!", path=["foo", "bar"])
275
+ match = max([shallow, deep], key=exceptions.relevance)
276
+ self.assertIs(match, shallow)
277
+
278
+ match = max([deep, shallow], key=exceptions.relevance)
279
+ self.assertIs(match, shallow)
280
+
281
+ def test_global_errors_are_even_better_matches(self):
282
+ shallow = exceptions.ValidationError("Oh no!", path=[])
283
+ deep = exceptions.ValidationError("Oh yes!", path=["foo"])
284
+
285
+ errors = sorted([shallow, deep], key=exceptions.relevance)
286
+ self.assertEqual(
287
+ [list(error.path) for error in errors],
288
+ [["foo"], []],
289
+ )
290
+
291
+ errors = sorted([deep, shallow], key=exceptions.relevance)
292
+ self.assertEqual(
293
+ [list(error.path) for error in errors],
294
+ [["foo"], []],
295
+ )
296
+
297
+ def test_weak_keywords_are_lower_priority(self):
298
+ weak = exceptions.ValidationError("Oh no!", path=[], validator="a")
299
+ normal = exceptions.ValidationError("Oh yes!", path=[], validator="b")
300
+
301
+ best_match = exceptions.by_relevance(weak="a")
302
+
303
+ match = max([weak, normal], key=best_match)
304
+ self.assertIs(match, normal)
305
+
306
+ match = max([normal, weak], key=best_match)
307
+ self.assertIs(match, normal)
308
+
309
+ def test_strong_keywords_are_higher_priority(self):
310
+ weak = exceptions.ValidationError("Oh no!", path=[], validator="a")
311
+ normal = exceptions.ValidationError("Oh yes!", path=[], validator="b")
312
+ strong = exceptions.ValidationError("Oh fine!", path=[], validator="c")
313
+
314
+ best_match = exceptions.by_relevance(weak="a", strong="c")
315
+
316
+ match = max([weak, normal, strong], key=best_match)
317
+ self.assertIs(match, strong)
318
+
319
+ match = max([strong, normal, weak], key=best_match)
320
+ self.assertIs(match, strong)
321
+
322
+
323
+ class TestErrorTree(TestCase):
324
+ def test_it_knows_how_many_total_errors_it_contains(self):
325
+ # FIXME: #442
326
+ errors = [
327
+ exceptions.ValidationError("Something", validator=i)
328
+ for i in range(8)
329
+ ]
330
+ tree = exceptions.ErrorTree(errors)
331
+ self.assertEqual(tree.total_errors, 8)
332
+
333
+ def test_it_contains_an_item_if_the_item_had_an_error(self):
334
+ errors = [exceptions.ValidationError("a message", path=["bar"])]
335
+ tree = exceptions.ErrorTree(errors)
336
+ self.assertIn("bar", tree)
337
+
338
+ def test_it_does_not_contain_an_item_if_the_item_had_no_error(self):
339
+ errors = [exceptions.ValidationError("a message", path=["bar"])]
340
+ tree = exceptions.ErrorTree(errors)
341
+ self.assertNotIn("foo", tree)
342
+
343
+ def test_keywords_that_failed_appear_in_errors_dict(self):
344
+ error = exceptions.ValidationError("a message", validator="foo")
345
+ tree = exceptions.ErrorTree([error])
346
+ self.assertEqual(tree.errors, {"foo": error})
347
+
348
+ def test_it_creates_a_child_tree_for_each_nested_path(self):
349
+ errors = [
350
+ exceptions.ValidationError("a bar message", path=["bar"]),
351
+ exceptions.ValidationError("a bar -> 0 message", path=["bar", 0]),
352
+ ]
353
+ tree = exceptions.ErrorTree(errors)
354
+ self.assertIn(0, tree["bar"])
355
+ self.assertNotIn(1, tree["bar"])
356
+
357
+ def test_children_have_their_errors_dicts_built(self):
358
+ e1, e2 = (
359
+ exceptions.ValidationError("1", validator="foo", path=["bar", 0]),
360
+ exceptions.ValidationError("2", validator="quux", path=["bar", 0]),
361
+ )
362
+ tree = exceptions.ErrorTree([e1, e2])
363
+ self.assertEqual(tree["bar"][0].errors, {"foo": e1, "quux": e2})
364
+
365
+ def test_multiple_errors_with_instance(self):
366
+ e1, e2 = (
367
+ exceptions.ValidationError(
368
+ "1",
369
+ validator="foo",
370
+ path=["bar", "bar2"],
371
+ instance="i1"),
372
+ exceptions.ValidationError(
373
+ "2",
374
+ validator="quux",
375
+ path=["foobar", 2],
376
+ instance="i2"),
377
+ )
378
+ exceptions.ErrorTree([e1, e2])
379
+
380
+ def test_it_does_not_contain_subtrees_that_are_not_in_the_instance(self):
381
+ error = exceptions.ValidationError("123", validator="foo", instance=[])
382
+ tree = exceptions.ErrorTree([error])
383
+
384
+ with self.assertRaises(IndexError):
385
+ tree[0]
386
+
387
+ def test_if_its_in_the_tree_anyhow_it_does_not_raise_an_error(self):
388
+ """
389
+ If a keyword refers to a path that isn't in the instance, the
390
+ tree still properly returns a subtree for that path.
391
+ """
392
+
393
+ error = exceptions.ValidationError(
394
+ "a message", validator="foo", instance={}, path=["foo"],
395
+ )
396
+ tree = exceptions.ErrorTree([error])
397
+ self.assertIsInstance(tree["foo"], exceptions.ErrorTree)
398
+
399
+ def test_iter(self):
400
+ e1, e2 = (
401
+ exceptions.ValidationError(
402
+ "1",
403
+ validator="foo",
404
+ path=["bar", "bar2"],
405
+ instance="i1"),
406
+ exceptions.ValidationError(
407
+ "2",
408
+ validator="quux",
409
+ path=["foobar", 2],
410
+ instance="i2"),
411
+ )
412
+ tree = exceptions.ErrorTree([e1, e2])
413
+ self.assertEqual(set(tree), {"bar", "foobar"})
414
+
415
+ def test_repr_single(self):
416
+ error = exceptions.ValidationError(
417
+ "1",
418
+ validator="foo",
419
+ path=["bar", "bar2"],
420
+ instance="i1",
421
+ )
422
+ tree = exceptions.ErrorTree([error])
423
+ self.assertEqual(repr(tree), "<ErrorTree (1 total error)>")
424
+
425
+ def test_repr_multiple(self):
426
+ e1, e2 = (
427
+ exceptions.ValidationError(
428
+ "1",
429
+ validator="foo",
430
+ path=["bar", "bar2"],
431
+ instance="i1"),
432
+ exceptions.ValidationError(
433
+ "2",
434
+ validator="quux",
435
+ path=["foobar", 2],
436
+ instance="i2"),
437
+ )
438
+ tree = exceptions.ErrorTree([e1, e2])
439
+ self.assertEqual(repr(tree), "<ErrorTree (2 total errors)>")
440
+
441
+ def test_repr_empty(self):
442
+ tree = exceptions.ErrorTree([])
443
+ self.assertEqual(repr(tree), "<ErrorTree (0 total errors)>")
444
+
445
+
446
+ class TestErrorInitReprStr(TestCase):
447
+ def make_error(self, **kwargs):
448
+ defaults = dict(
449
+ message="hello",
450
+ validator="type",
451
+ validator_value="string",
452
+ instance=5,
453
+ schema={"type": "string"},
454
+ )
455
+ defaults.update(kwargs)
456
+ return exceptions.ValidationError(**defaults)
457
+
458
+ def assertShows(self, expected, **kwargs):
459
+ expected = textwrap.dedent(expected).rstrip("\n")
460
+
461
+ error = self.make_error(**kwargs)
462
+ message_line, _, rest = str(error).partition("\n")
463
+ self.assertEqual(message_line, error.message)
464
+ self.assertEqual(rest, expected)
465
+
466
+ def test_it_calls_super_and_sets_args(self):
467
+ error = self.make_error()
468
+ self.assertGreater(len(error.args), 1)
469
+
470
+ def test_repr(self):
471
+ self.assertEqual(
472
+ repr(exceptions.ValidationError(message="Hello!")),
473
+ "<ValidationError: 'Hello!'>",
474
+ )
475
+
476
+ def test_unset_error(self):
477
+ error = exceptions.ValidationError("message")
478
+ self.assertEqual(str(error), "message")
479
+
480
+ kwargs = {
481
+ "validator": "type",
482
+ "validator_value": "string",
483
+ "instance": 5,
484
+ "schema": {"type": "string"},
485
+ }
486
+ # Just the message should show if any of the attributes are unset
487
+ for attr in kwargs:
488
+ k = dict(kwargs)
489
+ del k[attr]
490
+ error = exceptions.ValidationError("message", **k)
491
+ self.assertEqual(str(error), "message")
492
+
493
+ def test_empty_paths(self):
494
+ self.assertShows(
495
+ """
496
+ Failed validating 'type' in schema:
497
+ {'type': 'string'}
498
+
499
+ On instance:
500
+ 5
501
+ """,
502
+ path=[],
503
+ schema_path=[],
504
+ )
505
+
506
+ def test_one_item_paths(self):
507
+ self.assertShows(
508
+ """
509
+ Failed validating 'type' in schema:
510
+ {'type': 'string'}
511
+
512
+ On instance[0]:
513
+ 5
514
+ """,
515
+ path=[0],
516
+ schema_path=["items"],
517
+ )
518
+
519
+ def test_multiple_item_paths(self):
520
+ self.assertShows(
521
+ """
522
+ Failed validating 'type' in schema['items'][0]:
523
+ {'type': 'string'}
524
+
525
+ On instance[0]['a']:
526
+ 5
527
+ """,
528
+ path=[0, "a"],
529
+ schema_path=["items", 0, 1],
530
+ )
531
+
532
+ def test_uses_pprint(self):
533
+ self.assertShows(
534
+ """
535
+ Failed validating 'maxLength' in schema:
536
+ {0: 0,
537
+ 1: 1,
538
+ 2: 2,
539
+ 3: 3,
540
+ 4: 4,
541
+ 5: 5,
542
+ 6: 6,
543
+ 7: 7,
544
+ 8: 8,
545
+ 9: 9,
546
+ 10: 10,
547
+ 11: 11,
548
+ 12: 12,
549
+ 13: 13,
550
+ 14: 14,
551
+ 15: 15,
552
+ 16: 16,
553
+ 17: 17,
554
+ 18: 18,
555
+ 19: 19}
556
+
557
+ On instance:
558
+ [0,
559
+ 1,
560
+ 2,
561
+ 3,
562
+ 4,
563
+ 5,
564
+ 6,
565
+ 7,
566
+ 8,
567
+ 9,
568
+ 10,
569
+ 11,
570
+ 12,
571
+ 13,
572
+ 14,
573
+ 15,
574
+ 16,
575
+ 17,
576
+ 18,
577
+ 19,
578
+ 20,
579
+ 21,
580
+ 22,
581
+ 23,
582
+ 24]
583
+ """,
584
+ instance=list(range(25)),
585
+ schema=dict(zip(range(20), range(20))),
586
+ validator="maxLength",
587
+ )
588
+
589
+ def test_str_works_with_instances_having_overriden_eq_operator(self):
590
+ """
591
+ Check for #164 which rendered exceptions unusable when a
592
+ `ValidationError` involved instances with an `__eq__` method
593
+ that returned truthy values.
594
+ """
595
+
596
+ class DontEQMeBro:
597
+ def __eq__(this, other): # pragma: no cover
598
+ self.fail("Don't!")
599
+
600
+ def __ne__(this, other): # pragma: no cover
601
+ self.fail("Don't!")
602
+
603
+ instance = DontEQMeBro()
604
+ error = exceptions.ValidationError(
605
+ "a message",
606
+ validator="foo",
607
+ instance=instance,
608
+ validator_value="some",
609
+ schema="schema",
610
+ )
611
+ self.assertIn(repr(instance), str(error))
612
+
613
+
614
+ class TestHashable(TestCase):
615
+ def test_hashable(self):
616
+ set([exceptions.ValidationError("")])
617
+ set([exceptions.SchemaError("")])
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/test_format.py ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Tests for the parts of jsonschema related to the :kw:`format` keyword.
3
+ """
4
+
5
+ from unittest import TestCase
6
+
7
+ from jsonschema import FormatChecker, ValidationError
8
+ from jsonschema.exceptions import FormatError
9
+ from jsonschema.validators import Draft4Validator
10
+
11
+ BOOM = ValueError("Boom!")
12
+ BANG = ZeroDivisionError("Bang!")
13
+
14
+
15
+ def boom(thing):
16
+ if thing == "bang":
17
+ raise BANG
18
+ raise BOOM
19
+
20
+
21
+ class TestFormatChecker(TestCase):
22
+ def test_it_can_validate_no_formats(self):
23
+ checker = FormatChecker(formats=())
24
+ self.assertFalse(checker.checkers)
25
+
26
+ def test_it_raises_a_key_error_for_unknown_formats(self):
27
+ with self.assertRaises(KeyError):
28
+ FormatChecker(formats=["o noes"])
29
+
30
+ def test_it_can_register_cls_checkers(self):
31
+ original = dict(FormatChecker.checkers)
32
+ self.addCleanup(FormatChecker.checkers.pop, "boom")
33
+ with self.assertWarns(DeprecationWarning):
34
+ FormatChecker.cls_checks("boom")(boom)
35
+ self.assertEqual(
36
+ FormatChecker.checkers,
37
+ dict(original, boom=(boom, ())),
38
+ )
39
+
40
+ def test_it_can_register_checkers(self):
41
+ checker = FormatChecker()
42
+ checker.checks("boom")(boom)
43
+ self.assertEqual(
44
+ checker.checkers,
45
+ dict(FormatChecker.checkers, boom=(boom, ())),
46
+ )
47
+
48
+ def test_it_catches_registered_errors(self):
49
+ checker = FormatChecker()
50
+ checker.checks("boom", raises=type(BOOM))(boom)
51
+
52
+ with self.assertRaises(FormatError) as cm:
53
+ checker.check(instance=12, format="boom")
54
+
55
+ self.assertIs(cm.exception.cause, BOOM)
56
+ self.assertIs(cm.exception.__cause__, BOOM)
57
+ self.assertEqual(str(cm.exception), "12 is not a 'boom'")
58
+
59
+ # Unregistered errors should not be caught
60
+ with self.assertRaises(type(BANG)):
61
+ checker.check(instance="bang", format="boom")
62
+
63
+ def test_format_error_causes_become_validation_error_causes(self):
64
+ checker = FormatChecker()
65
+ checker.checks("boom", raises=ValueError)(boom)
66
+ validator = Draft4Validator({"format": "boom"}, format_checker=checker)
67
+
68
+ with self.assertRaises(ValidationError) as cm:
69
+ validator.validate("BOOM")
70
+
71
+ self.assertIs(cm.exception.cause, BOOM)
72
+ self.assertIs(cm.exception.__cause__, BOOM)
73
+
74
+ def test_format_checkers_come_with_defaults(self):
75
+ # This is bad :/ but relied upon.
76
+ # The docs for quite awhile recommended people do things like
77
+ # validate(..., format_checker=FormatChecker())
78
+ # We should change that, but we can't without deprecation...
79
+ checker = FormatChecker()
80
+ with self.assertRaises(FormatError):
81
+ checker.check(instance="not-an-ipv4", format="ipv4")
82
+
83
+ def test_repr(self):
84
+ checker = FormatChecker(formats=())
85
+ checker.checks("foo")(lambda thing: True) # pragma: no cover
86
+ checker.checks("bar")(lambda thing: True) # pragma: no cover
87
+ checker.checks("baz")(lambda thing: True) # pragma: no cover
88
+ self.assertEqual(
89
+ repr(checker),
90
+ "<FormatChecker checkers=['bar', 'baz', 'foo']>",
91
+ )
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/test_jsonschema_test_suite.py ADDED
@@ -0,0 +1,257 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Test runner for the JSON Schema official test suite
3
+
4
+ Tests comprehensive correctness of each draft's validator.
5
+
6
+ See https://github.com/json-schema-org/JSON-Schema-Test-Suite for details.
7
+ """
8
+
9
+ import sys
10
+
11
+ from jsonschema.tests._suite import Suite
12
+ import jsonschema
13
+
14
+ SUITE = Suite()
15
+ DRAFT3 = SUITE.version(name="draft3")
16
+ DRAFT4 = SUITE.version(name="draft4")
17
+ DRAFT6 = SUITE.version(name="draft6")
18
+ DRAFT7 = SUITE.version(name="draft7")
19
+ DRAFT201909 = SUITE.version(name="draft2019-09")
20
+ DRAFT202012 = SUITE.version(name="draft2020-12")
21
+
22
+
23
+ def skip(message, **kwargs):
24
+ def skipper(test):
25
+ if all(value == getattr(test, attr) for attr, value in kwargs.items()):
26
+ return message
27
+ return skipper
28
+
29
+
30
+ def missing_format(Validator):
31
+ def missing_format(test): # pragma: no cover
32
+ schema = test.schema
33
+ if (
34
+ schema is True
35
+ or schema is False
36
+ or "format" not in schema
37
+ or schema["format"] in Validator.FORMAT_CHECKER.checkers
38
+ or test.valid
39
+ ):
40
+ return
41
+
42
+ return f"Format checker {schema['format']!r} not found."
43
+ return missing_format
44
+
45
+
46
+ def complex_email_validation(test):
47
+ if test.subject != "email":
48
+ return
49
+
50
+ message = "Complex email validation is (intentionally) unsupported."
51
+ return skip(
52
+ message=message,
53
+ description="an invalid domain",
54
+ )(test) or skip(
55
+ message=message,
56
+ description="an invalid IPv4-address-literal",
57
+ )(test) or skip(
58
+ message=message,
59
+ description="dot after local part is not valid",
60
+ )(test) or skip(
61
+ message=message,
62
+ description="dot before local part is not valid",
63
+ )(test) or skip(
64
+ message=message,
65
+ description="two subsequent dots inside local part are not valid",
66
+ )(test)
67
+
68
+
69
+ if sys.version_info < (3, 9): # pragma: no cover
70
+ message = "Rejecting leading zeros is 3.9+"
71
+ allowed_leading_zeros = skip(
72
+ message=message,
73
+ subject="ipv4",
74
+ description="invalid leading zeroes, as they are treated as octals",
75
+ )
76
+ else:
77
+ def allowed_leading_zeros(test): # pragma: no cover
78
+ return
79
+
80
+
81
+ def leap_second(test):
82
+ message = "Leap seconds are unsupported."
83
+ return skip(
84
+ message=message,
85
+ subject="time",
86
+ description="a valid time string with leap second",
87
+ )(test) or skip(
88
+ message=message,
89
+ subject="time",
90
+ description="a valid time string with leap second, Zulu",
91
+ )(test) or skip(
92
+ message=message,
93
+ subject="time",
94
+ description="a valid time string with leap second with offset",
95
+ )(test) or skip(
96
+ message=message,
97
+ subject="time",
98
+ description="valid leap second, positive time-offset",
99
+ )(test) or skip(
100
+ message=message,
101
+ subject="time",
102
+ description="valid leap second, negative time-offset",
103
+ )(test) or skip(
104
+ message=message,
105
+ subject="time",
106
+ description="valid leap second, large positive time-offset",
107
+ )(test) or skip(
108
+ message=message,
109
+ subject="time",
110
+ description="valid leap second, large negative time-offset",
111
+ )(test) or skip(
112
+ message=message,
113
+ subject="time",
114
+ description="valid leap second, zero time-offset",
115
+ )(test) or skip(
116
+ message=message,
117
+ subject="date-time",
118
+ description="a valid date-time with a leap second, UTC",
119
+ )(test) or skip(
120
+ message=message,
121
+ subject="date-time",
122
+ description="a valid date-time with a leap second, with minus offset",
123
+ )(test)
124
+
125
+
126
+ TestDraft3 = DRAFT3.to_unittest_testcase(
127
+ DRAFT3.cases(),
128
+ DRAFT3.format_cases(),
129
+ DRAFT3.optional_cases_of(name="bignum"),
130
+ DRAFT3.optional_cases_of(name="non-bmp-regex"),
131
+ DRAFT3.optional_cases_of(name="zeroTerminatedFloats"),
132
+ Validator=jsonschema.Draft3Validator,
133
+ format_checker=jsonschema.Draft3Validator.FORMAT_CHECKER,
134
+ skip=lambda test: (
135
+ missing_format(jsonschema.Draft3Validator)(test)
136
+ or complex_email_validation(test)
137
+ ),
138
+ )
139
+
140
+
141
+ TestDraft4 = DRAFT4.to_unittest_testcase(
142
+ DRAFT4.cases(),
143
+ DRAFT4.format_cases(),
144
+ DRAFT4.optional_cases_of(name="bignum"),
145
+ DRAFT4.optional_cases_of(name="float-overflow"),
146
+ DRAFT4.optional_cases_of(name="non-bmp-regex"),
147
+ DRAFT4.optional_cases_of(name="zeroTerminatedFloats"),
148
+ Validator=jsonschema.Draft4Validator,
149
+ format_checker=jsonschema.Draft4Validator.FORMAT_CHECKER,
150
+ skip=lambda test: (
151
+ allowed_leading_zeros(test)
152
+ or leap_second(test)
153
+ or missing_format(jsonschema.Draft4Validator)(test)
154
+ or complex_email_validation(test)
155
+ ),
156
+ )
157
+
158
+
159
+ TestDraft6 = DRAFT6.to_unittest_testcase(
160
+ DRAFT6.cases(),
161
+ DRAFT6.format_cases(),
162
+ DRAFT6.optional_cases_of(name="bignum"),
163
+ DRAFT6.optional_cases_of(name="float-overflow"),
164
+ DRAFT6.optional_cases_of(name="non-bmp-regex"),
165
+ Validator=jsonschema.Draft6Validator,
166
+ format_checker=jsonschema.Draft6Validator.FORMAT_CHECKER,
167
+ skip=lambda test: (
168
+ allowed_leading_zeros(test)
169
+ or leap_second(test)
170
+ or missing_format(jsonschema.Draft6Validator)(test)
171
+ or complex_email_validation(test)
172
+ ),
173
+ )
174
+
175
+
176
+ TestDraft7 = DRAFT7.to_unittest_testcase(
177
+ DRAFT7.cases(),
178
+ DRAFT7.format_cases(),
179
+ DRAFT7.optional_cases_of(name="bignum"),
180
+ DRAFT7.optional_cases_of(name="cross-draft"),
181
+ DRAFT7.optional_cases_of(name="float-overflow"),
182
+ DRAFT7.optional_cases_of(name="non-bmp-regex"),
183
+ Validator=jsonschema.Draft7Validator,
184
+ format_checker=jsonschema.Draft7Validator.FORMAT_CHECKER,
185
+ skip=lambda test: (
186
+ allowed_leading_zeros(test)
187
+ or leap_second(test)
188
+ or missing_format(jsonschema.Draft7Validator)(test)
189
+ or complex_email_validation(test)
190
+ ),
191
+ )
192
+
193
+
194
+ TestDraft201909 = DRAFT201909.to_unittest_testcase(
195
+ DRAFT201909.cases(),
196
+ DRAFT201909.optional_cases_of(name="bignum"),
197
+ DRAFT201909.optional_cases_of(name="cross-draft"),
198
+ DRAFT201909.optional_cases_of(name="float-overflow"),
199
+ DRAFT201909.optional_cases_of(name="non-bmp-regex"),
200
+ DRAFT201909.optional_cases_of(name="refOfUnknownKeyword"),
201
+ Validator=jsonschema.Draft201909Validator,
202
+ skip=skip(
203
+ message="Vocabulary support is still in-progress.",
204
+ subject="vocabulary",
205
+ description=(
206
+ "no validation: invalid number, but it still validates"
207
+ ),
208
+ ),
209
+ )
210
+
211
+
212
+ TestDraft201909Format = DRAFT201909.to_unittest_testcase(
213
+ DRAFT201909.format_cases(),
214
+ name="TestDraft201909Format",
215
+ Validator=jsonschema.Draft201909Validator,
216
+ format_checker=jsonschema.Draft201909Validator.FORMAT_CHECKER,
217
+ skip=lambda test: (
218
+ complex_email_validation(test)
219
+ or allowed_leading_zeros(test)
220
+ or leap_second(test)
221
+ or missing_format(jsonschema.Draft201909Validator)(test)
222
+ or complex_email_validation(test)
223
+ ),
224
+ )
225
+
226
+
227
+ TestDraft202012 = DRAFT202012.to_unittest_testcase(
228
+ DRAFT202012.cases(),
229
+ DRAFT202012.optional_cases_of(name="bignum"),
230
+ DRAFT202012.optional_cases_of(name="cross-draft"),
231
+ DRAFT202012.optional_cases_of(name="float-overflow"),
232
+ DRAFT202012.optional_cases_of(name="non-bmp-regex"),
233
+ DRAFT202012.optional_cases_of(name="refOfUnknownKeyword"),
234
+ Validator=jsonschema.Draft202012Validator,
235
+ skip=skip(
236
+ message="Vocabulary support is still in-progress.",
237
+ subject="vocabulary",
238
+ description=(
239
+ "no validation: invalid number, but it still validates"
240
+ ),
241
+ ),
242
+ )
243
+
244
+
245
+ TestDraft202012Format = DRAFT202012.to_unittest_testcase(
246
+ DRAFT202012.format_cases(),
247
+ name="TestDraft202012Format",
248
+ Validator=jsonschema.Draft202012Validator,
249
+ format_checker=jsonschema.Draft202012Validator.FORMAT_CHECKER,
250
+ skip=lambda test: (
251
+ complex_email_validation(test)
252
+ or allowed_leading_zeros(test)
253
+ or leap_second(test)
254
+ or missing_format(jsonschema.Draft202012Validator)(test)
255
+ or complex_email_validation(test)
256
+ ),
257
+ )
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/test_types.py ADDED
@@ -0,0 +1,221 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Tests for the `TypeChecker`-based type interface.
3
+
4
+ The actual correctness of the type checking is handled in
5
+ `test_jsonschema_test_suite`; these tests check that TypeChecker
6
+ functions correctly at a more granular level.
7
+ """
8
+ from collections import namedtuple
9
+ from unittest import TestCase
10
+
11
+ from jsonschema import ValidationError, _keywords
12
+ from jsonschema._types import TypeChecker
13
+ from jsonschema.exceptions import UndefinedTypeCheck, UnknownType
14
+ from jsonschema.validators import Draft202012Validator, extend
15
+
16
+
17
+ def equals_2(checker, instance):
18
+ return instance == 2
19
+
20
+
21
+ def is_namedtuple(instance):
22
+ return isinstance(instance, tuple) and getattr(instance, "_fields", None)
23
+
24
+
25
+ def is_object_or_named_tuple(checker, instance):
26
+ if Draft202012Validator.TYPE_CHECKER.is_type(instance, "object"):
27
+ return True
28
+ return is_namedtuple(instance)
29
+
30
+
31
+ class TestTypeChecker(TestCase):
32
+ def test_is_type(self):
33
+ checker = TypeChecker({"two": equals_2})
34
+ self.assertEqual(
35
+ (
36
+ checker.is_type(instance=2, type="two"),
37
+ checker.is_type(instance="bar", type="two"),
38
+ ),
39
+ (True, False),
40
+ )
41
+
42
+ def test_is_unknown_type(self):
43
+ with self.assertRaises(UndefinedTypeCheck) as e:
44
+ TypeChecker().is_type(4, "foobar")
45
+ self.assertIn(
46
+ "'foobar' is unknown to this type checker",
47
+ str(e.exception),
48
+ )
49
+ self.assertTrue(
50
+ e.exception.__suppress_context__,
51
+ msg="Expected the internal KeyError to be hidden.",
52
+ )
53
+
54
+ def test_checks_can_be_added_at_init(self):
55
+ checker = TypeChecker({"two": equals_2})
56
+ self.assertEqual(checker, TypeChecker().redefine("two", equals_2))
57
+
58
+ def test_redefine_existing_type(self):
59
+ self.assertEqual(
60
+ TypeChecker().redefine("two", object()).redefine("two", equals_2),
61
+ TypeChecker().redefine("two", equals_2),
62
+ )
63
+
64
+ def test_remove(self):
65
+ self.assertEqual(
66
+ TypeChecker({"two": equals_2}).remove("two"),
67
+ TypeChecker(),
68
+ )
69
+
70
+ def test_remove_unknown_type(self):
71
+ with self.assertRaises(UndefinedTypeCheck) as context:
72
+ TypeChecker().remove("foobar")
73
+ self.assertIn("foobar", str(context.exception))
74
+
75
+ def test_redefine_many(self):
76
+ self.assertEqual(
77
+ TypeChecker().redefine_many({"foo": int, "bar": str}),
78
+ TypeChecker().redefine("foo", int).redefine("bar", str),
79
+ )
80
+
81
+ def test_remove_multiple(self):
82
+ self.assertEqual(
83
+ TypeChecker({"foo": int, "bar": str}).remove("foo", "bar"),
84
+ TypeChecker(),
85
+ )
86
+
87
+ def test_type_check_can_raise_key_error(self):
88
+ """
89
+ Make sure no one writes:
90
+
91
+ try:
92
+ self._type_checkers[type](...)
93
+ except KeyError:
94
+
95
+ ignoring the fact that the function itself can raise that.
96
+ """
97
+
98
+ error = KeyError("Stuff")
99
+
100
+ def raises_keyerror(checker, instance):
101
+ raise error
102
+
103
+ with self.assertRaises(KeyError) as context:
104
+ TypeChecker({"foo": raises_keyerror}).is_type(4, "foo")
105
+
106
+ self.assertIs(context.exception, error)
107
+
108
+ def test_repr(self):
109
+ checker = TypeChecker({"foo": is_namedtuple, "bar": is_namedtuple})
110
+ self.assertEqual(repr(checker), "<TypeChecker types={'bar', 'foo'}>")
111
+
112
+
113
+ class TestCustomTypes(TestCase):
114
+ def test_simple_type_can_be_extended(self):
115
+ def int_or_str_int(checker, instance):
116
+ if not isinstance(instance, (int, str)):
117
+ return False
118
+ try:
119
+ int(instance)
120
+ except ValueError:
121
+ return False
122
+ return True
123
+
124
+ CustomValidator = extend(
125
+ Draft202012Validator,
126
+ type_checker=Draft202012Validator.TYPE_CHECKER.redefine(
127
+ "integer", int_or_str_int,
128
+ ),
129
+ )
130
+ validator = CustomValidator({"type": "integer"})
131
+
132
+ validator.validate(4)
133
+ validator.validate("4")
134
+
135
+ with self.assertRaises(ValidationError):
136
+ validator.validate(4.4)
137
+
138
+ with self.assertRaises(ValidationError):
139
+ validator.validate("foo")
140
+
141
+ def test_object_can_be_extended(self):
142
+ schema = {"type": "object"}
143
+
144
+ Point = namedtuple("Point", ["x", "y"])
145
+
146
+ type_checker = Draft202012Validator.TYPE_CHECKER.redefine(
147
+ "object", is_object_or_named_tuple,
148
+ )
149
+
150
+ CustomValidator = extend(
151
+ Draft202012Validator,
152
+ type_checker=type_checker,
153
+ )
154
+ validator = CustomValidator(schema)
155
+
156
+ validator.validate(Point(x=4, y=5))
157
+
158
+ def test_object_extensions_require_custom_validators(self):
159
+ schema = {"type": "object", "required": ["x"]}
160
+
161
+ type_checker = Draft202012Validator.TYPE_CHECKER.redefine(
162
+ "object", is_object_or_named_tuple,
163
+ )
164
+
165
+ CustomValidator = extend(
166
+ Draft202012Validator,
167
+ type_checker=type_checker,
168
+ )
169
+ validator = CustomValidator(schema)
170
+
171
+ Point = namedtuple("Point", ["x", "y"])
172
+ # Cannot handle required
173
+ with self.assertRaises(ValidationError):
174
+ validator.validate(Point(x=4, y=5))
175
+
176
+ def test_object_extensions_can_handle_custom_validators(self):
177
+ schema = {
178
+ "type": "object",
179
+ "required": ["x"],
180
+ "properties": {"x": {"type": "integer"}},
181
+ }
182
+
183
+ type_checker = Draft202012Validator.TYPE_CHECKER.redefine(
184
+ "object", is_object_or_named_tuple,
185
+ )
186
+
187
+ def coerce_named_tuple(fn):
188
+ def coerced(validator, value, instance, schema):
189
+ if is_namedtuple(instance):
190
+ instance = instance._asdict()
191
+ return fn(validator, value, instance, schema)
192
+ return coerced
193
+
194
+ required = coerce_named_tuple(_keywords.required)
195
+ properties = coerce_named_tuple(_keywords.properties)
196
+
197
+ CustomValidator = extend(
198
+ Draft202012Validator,
199
+ type_checker=type_checker,
200
+ validators={"required": required, "properties": properties},
201
+ )
202
+
203
+ validator = CustomValidator(schema)
204
+
205
+ Point = namedtuple("Point", ["x", "y"])
206
+ # Can now process required and properties
207
+ validator.validate(Point(x=4, y=5))
208
+
209
+ with self.assertRaises(ValidationError):
210
+ validator.validate(Point(x="not an integer", y=5))
211
+
212
+ # As well as still handle objects.
213
+ validator.validate({"x": 4, "y": 5})
214
+
215
+ with self.assertRaises(ValidationError):
216
+ validator.validate({"x": "not an integer", "y": 5})
217
+
218
+ def test_unknown_type(self):
219
+ with self.assertRaises(UnknownType) as e:
220
+ Draft202012Validator({}).is_type(12, "some unknown type")
221
+ self.assertIn("'some unknown type'", str(e.exception))
platform/dataops/dto/.venv/lib/python3.12/site-packages/jsonschema/tests/test_utils.py ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from unittest import TestCase
2
+
3
+ from jsonschema._utils import equal
4
+
5
+
6
+ class TestEqual(TestCase):
7
+ def test_none(self):
8
+ self.assertTrue(equal(None, None))
9
+
10
+
11
+ class TestDictEqual(TestCase):
12
+ def test_equal_dictionaries(self):
13
+ dict_1 = {"a": "b", "c": "d"}
14
+ dict_2 = {"c": "d", "a": "b"}
15
+ self.assertTrue(equal(dict_1, dict_2))
16
+
17
+ def test_missing_key(self):
18
+ dict_1 = {"a": "b", "c": "d"}
19
+ dict_2 = {"c": "d", "x": "b"}
20
+ self.assertFalse(equal(dict_1, dict_2))
21
+
22
+ def test_additional_key(self):
23
+ dict_1 = {"a": "b", "c": "d"}
24
+ dict_2 = {"c": "d", "a": "b", "x": "x"}
25
+ self.assertFalse(equal(dict_1, dict_2))
26
+
27
+ def test_missing_value(self):
28
+ dict_1 = {"a": "b", "c": "d"}
29
+ dict_2 = {"c": "d", "a": "x"}
30
+ self.assertFalse(equal(dict_1, dict_2))
31
+
32
+ def test_empty_dictionaries(self):
33
+ dict_1 = {}
34
+ dict_2 = {}
35
+ self.assertTrue(equal(dict_1, dict_2))
36
+
37
+ def test_one_none(self):
38
+ dict_1 = None
39
+ dict_2 = {"a": "b", "c": "d"}
40
+ self.assertFalse(equal(dict_1, dict_2))
41
+
42
+ def test_same_item(self):
43
+ dict_1 = {"a": "b", "c": "d"}
44
+ self.assertTrue(equal(dict_1, dict_1))
45
+
46
+ def test_nested_equal(self):
47
+ dict_1 = {"a": {"a": "b", "c": "d"}, "c": "d"}
48
+ dict_2 = {"c": "d", "a": {"a": "b", "c": "d"}}
49
+ self.assertTrue(equal(dict_1, dict_2))
50
+
51
+ def test_nested_dict_unequal(self):
52
+ dict_1 = {"a": {"a": "b", "c": "d"}, "c": "d"}
53
+ dict_2 = {"c": "d", "a": {"a": "b", "c": "x"}}
54
+ self.assertFalse(equal(dict_1, dict_2))
55
+
56
+ def test_mixed_nested_equal(self):
57
+ dict_1 = {"a": ["a", "b", "c", "d"], "c": "d"}
58
+ dict_2 = {"c": "d", "a": ["a", "b", "c", "d"]}
59
+ self.assertTrue(equal(dict_1, dict_2))
60
+
61
+ def test_nested_list_unequal(self):
62
+ dict_1 = {"a": ["a", "b", "c", "d"], "c": "d"}
63
+ dict_2 = {"c": "d", "a": ["b", "c", "d", "a"]}
64
+ self.assertFalse(equal(dict_1, dict_2))
65
+
66
+
67
+ class TestListEqual(TestCase):
68
+ def test_equal_lists(self):
69
+ list_1 = ["a", "b", "c"]
70
+ list_2 = ["a", "b", "c"]
71
+ self.assertTrue(equal(list_1, list_2))
72
+
73
+ def test_unsorted_lists(self):
74
+ list_1 = ["a", "b", "c"]
75
+ list_2 = ["b", "b", "a"]
76
+ self.assertFalse(equal(list_1, list_2))
77
+
78
+ def test_first_list_larger(self):
79
+ list_1 = ["a", "b", "c"]
80
+ list_2 = ["a", "b"]
81
+ self.assertFalse(equal(list_1, list_2))
82
+
83
+ def test_second_list_larger(self):
84
+ list_1 = ["a", "b"]
85
+ list_2 = ["a", "b", "c"]
86
+ self.assertFalse(equal(list_1, list_2))
87
+
88
+ def test_list_with_none_unequal(self):
89
+ list_1 = ["a", "b", None]
90
+ list_2 = ["a", "b", "c"]
91
+ self.assertFalse(equal(list_1, list_2))
92
+
93
+ list_1 = ["a", "b", None]
94
+ list_2 = [None, "b", "c"]
95
+ self.assertFalse(equal(list_1, list_2))
96
+
97
+ def test_list_with_none_equal(self):
98
+ list_1 = ["a", None, "c"]
99
+ list_2 = ["a", None, "c"]
100
+ self.assertTrue(equal(list_1, list_2))
101
+
102
+ def test_empty_list(self):
103
+ list_1 = []
104
+ list_2 = []
105
+ self.assertTrue(equal(list_1, list_2))
106
+
107
+ def test_one_none(self):
108
+ list_1 = None
109
+ list_2 = []
110
+ self.assertFalse(equal(list_1, list_2))
111
+
112
+ def test_same_list(self):
113
+ list_1 = ["a", "b", "c"]
114
+ self.assertTrue(equal(list_1, list_1))
115
+
116
+ def test_equal_nested_lists(self):
117
+ list_1 = ["a", ["b", "c"], "d"]
118
+ list_2 = ["a", ["b", "c"], "d"]
119
+ self.assertTrue(equal(list_1, list_2))
120
+
121
+ def test_unequal_nested_lists(self):
122
+ list_1 = ["a", ["b", "c"], "d"]
123
+ list_2 = ["a", [], "c"]
124
+ self.assertFalse(equal(list_1, list_2))