You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This means that the same lambda_handler instance will be used for all testcases, them being in different files or not. Which again means that the internal lookup http_methods will be scrampled.
A fix for this is to either put your import statements locally in your test functions like:
class test(unittest.TestCase):
def test_this(self):
from my_module import lambda_handler
lambda_handler.handle("get")
or stop using the singleton and instantiate your own like:
from lambdarest import create_lambda_handler
lambda_handler = create_lambda_handler()
The text was updated successfully, but these errors were encountered:
when unittesting code like the following
The
lambda_handler
singleton will stay instantiated between testcases since the module is not torn down completely (unittest does this to be able to later on gather the test results see https://chrisbailey.blogs.ilrt.org/2013/05/19/pythons-leaky-testcase-aka-hidden-gotchas-using-self/)This means that the same lambda_handler instance will be used for all testcases, them being in different files or not. Which again means that the internal lookup
http_methods
will be scrampled.A fix for this is to either put your import statements locally in your test functions like:
or stop using the singleton and instantiate your own like:
The text was updated successfully, but these errors were encountered: