garnaat / placebo

Make boto3 calls that look real but have no effect.
Apache License 2.0
394 stars 28 forks source link

"RuntimeError: maximum recursion depth exceeded..." when using placebo.attach two times #57

Open wvidana opened 7 years ago

wvidana commented 7 years ago

When using placebo.attach() on two different methods within a unittest Class, on the second method the code aborts due to maximum recursion depth exceeded.

This is the failing line

File "...placebo/pill.py", line 109, in _init_method
   super_cls.__init__(self, *args, **kwargs)

This was called by botocore/client

ghost commented 7 years ago

Stumbled upon the same error; the pill is not unregistering from the 'creating-client-class' Boto event, so if you use a singleton Boto session, the event is fired multiple times for subsequent tests. I don't have the bandwidth to submit a PR, but it can be bypassed with

BOTO_SESSION.events.unregister(
    'creating-client-class',
    pill._create_client,
)

at the end of the unit test

kmonihen commented 6 years ago

I built a decorator class that helps you switch client and/or data_paths between tests, which helped me with this issue: https://github.com/kmonihen/BluePill