Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap and proxy method calls for builtin objects rather than error(?) #3

Open
bkabrda opened this issue Dec 3, 2015 · 0 comments
Open

Comments

@bkabrda
Copy link
Collaborator

bkabrda commented Dec 3, 2015

It could be useful to do something like the following to ensure all open() calls have a corresponding close(). Unfortunately it's a lot more cumbersome ATM due to inability to directly proxy for instances of builtin objects.

real_open = open
def wrap_open(*k, *kw):
  """ this could be a lambda one-liner even"""
  f = real_open(*k, **kw)
  flexmock(f).should_call('close').with_args().once
  return f

flexmock(__builtins__, open=wrap_open)

Original issue: has207/flexmock#82

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant