@@ -877,26 +877,30 @@ class TestThreadSafeMode:
877877 def reset_thread_safe (self ):
878878 """Reset thread_safe before and after each test."""
879879 from datajoint import settings
880+
880881 object .__setattr__ (settings .config , "thread_safe" , False )
881882 yield
882883 object .__setattr__ (settings .config , "thread_safe" , False )
883884
884885 def test_thread_safe_default_false (self ):
885886 """Thread-safe mode is disabled by default."""
886887 from datajoint .settings import Config
888+
887889 cfg = Config ()
888890 assert cfg .thread_safe is False
889891
890892 def test_thread_safe_can_be_enabled (self ):
891893 """Thread-safe mode can be enabled."""
892894 from datajoint import settings
895+
893896 settings .config .thread_safe = True
894897 assert settings .config .thread_safe is True
895898
896899 def test_thread_safe_one_way_lock (self ):
897900 """Once enabled, thread_safe cannot be disabled."""
898901 from datajoint import settings
899902 from datajoint .errors import ThreadSafetyError
903+
900904 settings .config .thread_safe = True
901905 with pytest .raises (ThreadSafetyError , match = "Cannot disable" ):
902906 settings .config .thread_safe = False
@@ -905,6 +909,7 @@ def test_getitem_blocked_in_thread_safe_mode(self):
905909 """Dict-like config access raises ThreadSafetyError in thread-safe mode."""
906910 from datajoint import settings
907911 from datajoint .errors import ThreadSafetyError
912+
908913 settings .config .thread_safe = True
909914 with pytest .raises (ThreadSafetyError , match = "Global config is inaccessible" ):
910915 _ = settings .config ["database.host" ]
@@ -913,6 +918,7 @@ def test_setitem_blocked_in_thread_safe_mode(self):
913918 """Dict-like config modification raises ThreadSafetyError in thread-safe mode."""
914919 from datajoint import settings
915920 from datajoint .errors import ThreadSafetyError
921+
916922 settings .config .thread_safe = True
917923 with pytest .raises (ThreadSafetyError , match = "Global config is inaccessible" ):
918924 settings .config ["database.host" ] = "newhost"
@@ -921,13 +927,15 @@ def test_attribute_access_blocked_in_thread_safe_mode(self):
921927 """Attribute access is also blocked in thread-safe mode."""
922928 from datajoint import settings
923929 from datajoint .errors import ThreadSafetyError
930+
924931 settings .config .thread_safe = True
925932 with pytest .raises (ThreadSafetyError , match = "Global config is inaccessible" ):
926933 _ = settings .config .database
927934
928935 def test_thread_safe_always_readable (self ):
929936 """The thread_safe setting itself is always readable."""
930937 from datajoint import settings
938+
931939 settings .config .thread_safe = True
932940 # Should not raise
933941 assert settings .config .thread_safe is True
@@ -936,6 +944,7 @@ def test_thread_safe_always_readable(self):
936944 def test_private_attributes_accessible (self ):
937945 """Private attributes (starting with _) are accessible in thread-safe mode."""
938946 from datajoint import settings
947+
939948 settings .config .thread_safe = True
940949 # Private attributes should be accessible for internal operations
941950 _ = settings .config ._config_path # Should not raise
0 commit comments