diff options
author | Julian Berman <Julian@GrayVines.com> | 2023-03-20 13:01:45 -0400 |
---|---|---|
committer | Julian Berman <Julian@GrayVines.com> | 2023-03-20 13:01:45 -0400 |
commit | 529b57aefb4810866c3de0750349fb227fac816e (patch) | |
tree | 090beb89818d6751f5df2abb979afc9706031573 /jsonschema | |
parent | abc4fcf5e49d3a4003c3b3cad5c425cfb53b72af (diff) | |
download | jsonschema-529b57aefb4810866c3de0750349fb227fac816e.tar.gz |
Bump the minimum jsonschema-specifications/rpds versions to avoid #1059v4.18.0a2
This should re-enable validating from a thread other than the one that
originall imported jsonschema.
Diffstat (limited to 'jsonschema')
-rw-r--r-- | jsonschema/tests/test_validators.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/jsonschema/tests/test_validators.py b/jsonschema/tests/test_validators.py index 8afdbe4..a9b7f6a 100644 --- a/jsonschema/tests/test_validators.py +++ b/jsonschema/tests/test_validators.py @@ -2115,6 +2115,37 @@ class TestValidate(TestCase): self.assertIn("12 is less than the minimum of 20", str(e.exception)) +class TestThreading(TestCase): + """ + Threading-related functionality tests. + + jsonschema doesn't promise thread safety, and its validation behavior + across multiple threads may change at any time, but that means it isn't + safe to share *validators* across threads, not that anytime one has + multiple threads that jsonschema won't work (it certainly is intended to). + + These tests ensure that this minimal level of functionality continues to + work. + """ + + def test_validation_across_a_second_thread(self): + failed = [] + + def validate(): + try: + validators.validate(instance=37, schema=True) + except: # noqa: E722, pragma: no cover + failed.append(sys.exc_info()) + + validate() # just verify it succeeds + + from threading import Thread + thread = Thread(target=validate) + thread.start() + thread.join() + self.assertEqual((thread.is_alive(), failed), (False, [])) + + class TestRefResolver(TestCase): base_uri = "" |