Skip to content

Commit 7b3d0f8

Browse files
authored
Merge pull request #45 from preearor/main
Add Support for / in handler name
2 parents a772d90 + 484d932 commit 7b3d0f8

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

awslambdaric/bootstrap.py

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def _get_handler(handler):
3636
"Cannot use built-in module {} as a handler module".format(modname),
3737
)
3838
return make_fault_handler(fault)
39+
modname = modname.replace("/", ".")
3940
m = importlib.import_module(modname)
4041
except ImportError as e:
4142
fault = FaultException(

tests/test_bootstrap.py

+18
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,12 @@ def test_get_event_handler_missing_error(self):
780780
returned_exception,
781781
)
782782

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+
783789
def test_get_event_handler_build_in_conflict(self):
784790
response_handler = bootstrap._get_handler("sys.hello")
785791
with self.assertRaises(FaultException) as cm:
@@ -793,6 +799,18 @@ def test_get_event_handler_build_in_conflict(self):
793799
returned_exception,
794800
)
795801

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+
796814

797815
class TestContentType(unittest.TestCase):
798816
def setUp(self):
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def my_handler():
2+
return "Same name as Built in module, but different path"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def my_handler():
2+
return "Good with slash"

0 commit comments

Comments
 (0)