File tree 4 files changed +23
-0
lines changed
test_built_in_module_name
4 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ def _get_handler(handler):
36
36
"Cannot use built-in module {} as a handler module" .format (modname ),
37
37
)
38
38
return make_fault_handler (fault )
39
+ modname = modname .replace ("/" , "." )
39
40
m = importlib .import_module (modname )
40
41
except ImportError as e :
41
42
fault = FaultException (
Original file line number Diff line number Diff line change @@ -780,6 +780,12 @@ def test_get_event_handler_missing_error(self):
780
780
returned_exception ,
781
781
)
782
782
783
+ def test_get_event_handler_slash (self ):
784
+ importlib .invalidate_caches ()
785
+ handler_name = "tests/test_handler_with_slash/test_handler.my_handler"
786
+ response_handler = bootstrap ._get_handler (handler_name )
787
+ response_handler ()
788
+
783
789
def test_get_event_handler_build_in_conflict (self ):
784
790
response_handler = bootstrap ._get_handler ("sys.hello" )
785
791
with self .assertRaises (FaultException ) as cm :
@@ -793,6 +799,18 @@ def test_get_event_handler_build_in_conflict(self):
793
799
returned_exception ,
794
800
)
795
801
802
+ def test_get_event_handler_doesnt_throw_build_in_module_name_slash (self ):
803
+ response_handler = bootstrap ._get_handler (
804
+ "tests/test_built_in_module_name/sys.my_handler"
805
+ )
806
+ response_handler ()
807
+
808
+ def test_get_event_handler_doent_throw_build_in_module_name (self ):
809
+ response_handler = bootstrap ._get_handler (
810
+ "tests.test_built_in_module_name.sys.my_handler"
811
+ )
812
+ response_handler ()
813
+
796
814
797
815
class TestContentType (unittest .TestCase ):
798
816
def setUp (self ):
Original file line number Diff line number Diff line change
1
+ def my_handler ():
2
+ return "Same name as Built in module, but different path"
Original file line number Diff line number Diff line change
1
+ def my_handler ():
2
+ return "Good with slash"
You can’t perform that action at this time.
0 commit comments