From 529b57aefb4810866c3de0750349fb227fac816e Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 20 Mar 2023 13:01:45 -0400 Subject: Bump the minimum jsonschema-specifications/rpds versions to avoid #1059 This should re-enable validating from a thread other than the one that originall imported jsonschema. --- jsonschema/tests/test_validators.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'jsonschema') 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 = "" -- cgit v1.2.1