@pytest.yield_fixture()
def use_vcr(request, monkeypatch):
 if (VCR_RECORD_MODE == u'off'):
  (yield None)
 else:
  module = request.module.__name__.split(u'tests.')[(-1)]
  class_name = request.cls.__name__
  cassette_name = u'.'.join([module, class_name, request.function.__name__])
  cassette_path = os.path.join(VCR_CASSETTE_DIR, cassette_name)
  online = True
  if (vcr.record_mode == u'none'):
   online = False
  elif (vcr.record_mode == u'once'):
   online = (not os.path.exists(cassette_path))
  if (not online):
   log.debug(u'Disabling domain limiters during VCR playback.')
   monkeypatch.setattr(u'flexget.utils.requests.limit_domains', mock.Mock())
  with vcr.use_cassette(path=cassette_path) as cassette:
   (yield cassette)

@ pytest . yield_fixture ( ) def use_vcr ( request , monkeypatch ) : if ( VCR_RECORD_MODE == u'off' ) : ( yield None ) else : module = request . module . __name__ . split ( u'tests.' ) [ ( - 1 ) ] class_name = request . cls . __name__ cassette_name = u'.' . join ( [ module , class_name , request . function . __name__ ] ) cassette_path = os . path . join ( VCR_CASSETTE_DIR , cassette_name ) online = True if ( vcr . record_mode == u'none' ) : online = False elif ( vcr . record_mode == u'once' ) : online = ( not os . path . exists ( cassette_path ) ) if ( not online ) : log . debug ( u'Disabling domain limiters during VCR playback.' ) monkeypatch . setattr ( u'flexget.utils.requests.limit_domains' , mock . Mock ( ) ) with vcr . use_cassette ( path = cassette_path ) as cassette : ( yield cassette )
this fixture is applied automatically to any test using the online mark .