1717import os
1818import unittest
1919from builtins import open
20+ import inspect
2021
2122from linebot import (
2223 SignatureValidator , WebhookParser , WebhookHandler
2930 LocationMessage , StickerMessage , FileMessage ,
3031 SourceUser , SourceRoom , SourceGroup ,
3132 DeviceLink , DeviceUnlink , ScenarioResult , ActionResult )
33+ from linebot .utils import PY3
3234
3335
3436class TestSignatureValidator (unittest .TestCase ):
@@ -529,6 +531,15 @@ def test_handler(self):
529531
530532class TestInvokeWebhookHandler (unittest .TestCase ):
531533 def setUp (self ):
534+ def wrap (func ):
535+ def wrapper (* args ):
536+ if PY3 :
537+ arg_spec = inspect .getfullargspec (func )
538+ else :
539+ arg_spec = inspect .getargspec (func )
540+ return func (* args [0 :len (arg_spec .args )])
541+ return wrapper
542+
532543 def func_with_0_args ():
533544 assert True
534545
@@ -547,13 +558,44 @@ def func_with_2_args_with_default(arg1=False, arg2=False):
547558 def func_with_1_arg_and_1_arg_with_default (arg1 , arg2 = False ):
548559 assert arg1 and arg2
549560
561+ @wrap
562+ def wrapped_func_with_0_args ():
563+ assert True
564+
565+ @wrap
566+ def wrapped_func_with_1_arg (arg ):
567+ assert arg
568+
569+ @wrap
570+ def wrapped_func_with_2_args (arg1 , arg2 ):
571+ assert arg1 and arg2
572+
573+ @wrap
574+ def wrapped_func_with_1_arg_with_default (arg = False ):
575+ assert arg
576+
577+ @wrap
578+ def wrapped_func_with_2_args_with_default (arg1 = False , arg2 = False ):
579+ assert arg1 and arg2
580+
581+ @wrap
582+ def wrapped_func_with_1_arg_and_1_arg_with_default (
583+ arg1 , arg2 = False ):
584+ assert arg1 and arg2
585+
550586 self .functions = [
551587 func_with_0_args ,
552588 func_with_1_arg ,
553589 func_with_2_args ,
554590 func_with_1_arg_with_default ,
555591 func_with_2_args_with_default ,
556592 func_with_1_arg_and_1_arg_with_default ,
593+ wrapped_func_with_0_args ,
594+ wrapped_func_with_1_arg ,
595+ wrapped_func_with_2_args ,
596+ wrapped_func_with_1_arg_with_default ,
597+ wrapped_func_with_2_args_with_default ,
598+ wrapped_func_with_1_arg_and_1_arg_with_default ,
557599 ]
558600
559601 def test_invoke_func (self ):
0 commit comments