@contextmanager
def override_provides(category, spec_list):
 old_provides = _provide_specs[category]
 _uncache(category)
 _provide_specs[category] = spec_list
 try:
  (yield)
 finally:
  _uncache(category)
  _provide_specs[category] = old_provides

@ contextmanager def override_provides ( category , spec_list ) : old_provides = _provide_specs [ category ] _uncache ( category ) _provide_specs [ category ] = spec_list try : ( yield ) finally : _uncache ( category ) _provide_specs [ category ] = old_provides
context manager to override provides for a given category .