File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed
jupyter_server/services/contents Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -127,7 +127,7 @@ def _validate_pre_save_hook(self, proposal):
127
127
value = import_item (self .pre_save_hook )
128
128
if not callable (value ):
129
129
raise TraitError ("pre_save_hook must be callable" )
130
- if self .pre_save_hook is not None :
130
+ if callable ( self .pre_save_hook ) :
131
131
warnings .warn (
132
132
f"Overriding existing pre_save_hook ({ self .pre_save_hook .__name__ } ) with a new one ({ value .__name__ } )." ,
133
133
stacklevel = 2 ,
@@ -162,7 +162,7 @@ def _validate_post_save_hook(self, proposal):
162
162
value = import_item (value )
163
163
if not callable (value ):
164
164
raise TraitError ("post_save_hook must be callable" )
165
- if self .post_save_hook is not None :
165
+ if callable ( self .post_save_hook ) :
166
166
warnings .warn (
167
167
f"Overriding existing post_save_hook ({ self .post_save_hook .__name__ } ) with a new one ({ value .__name__ } )." ,
168
168
stacklevel = 2 ,
Original file line number Diff line number Diff line change @@ -18,6 +18,30 @@ def test_config_did_something(jp_server_config, jp_serverapp):
18
18
)
19
19
20
20
21
+ def example_pre_save_hook ():
22
+ pass
23
+
24
+
25
+ def example_post_save_hook ():
26
+ pass
27
+
28
+
29
+ @pytest .mark .parametrize (
30
+ "jp_server_config" ,
31
+ [
32
+ {
33
+ "ContentsManager" : {
34
+ "pre_save_hook" : "tests.services.contents.test_config.example_pre_save_hook" ,
35
+ "post_save_hook" : "tests.services.contents.test_config.example_post_save_hook" ,
36
+ },
37
+ }
38
+ ],
39
+ )
40
+ def test_pre_post_save_hook_config (jp_serverapp , jp_server_config ):
41
+ assert jp_serverapp .contents_manager .pre_save_hook .__name__ == "example_pre_save_hook"
42
+ assert jp_serverapp .contents_manager .post_save_hook .__name__ == "example_post_save_hook"
43
+
44
+
21
45
async def test_async_contents_manager (jp_configurable_serverapp ):
22
46
config = {"ContentsManager" : {"checkpoints_class" : AsyncCheckpoints }}
23
47
argv = [
You can’t perform that action at this time.
0 commit comments