<s> from __future__ import absolute_import , division , print_function , unicode_literals <EOL> from os . path import join , dirname , realpath <EOL> from vcr import VCR <EOL> from vcr . serializers import yamlserializer <EOL> TOP = realpath ( join ( dirname ( dirname ( __file__ ) ) , '<STR_LIT:..>' ) ) <EOL> FIXTURES_ROOT = join ( TOP , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def filter_x_headers ( headers ) : <EOL> for k in list ( headers . keys ( ) ) : <EOL> if k . startswith ( '<STR_LIT>' ) : <EOL> headers . pop ( k ) <EOL> class CustomSerializer : <EOL> @ staticmethod <EOL> def serialize ( cassette_dict ) : <EOL> for i in cassette_dict [ '<STR_LIT>' ] : <EOL> i [ '<STR_LIT>' ] [ '<STR_LIT>' ] = { } <EOL> response_headers = i [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> response_headers . pop ( '<STR_LIT>' , None ) <EOL> response_headers . pop ( '<STR_LIT:date>' , None ) <EOL> response_headers . pop ( '<STR_LIT>' , None ) <EOL> filter_x_headers ( response_headers ) <EOL> return yamlserializer . serialize ( cassette_dict ) <EOL> @ staticmethod <EOL> def deserialize ( cassette_str ) : <EOL> return yamlserializer . deserialize ( cassette_str ) <EOL> vcr = VCR ( <EOL> cassette_library_dir = FIXTURES_ROOT , <EOL> record_mode = '<STR_LIT>' , <EOL> match_on = [ '<STR_LIT:url>' , '<STR_LIT>' ] , <EOL> ) <EOL> vcr . register_serializer ( '<STR_LIT>' , CustomSerializer ) <EOL> def use_cassette ( name ) : <EOL> return vcr . use_cassette ( <EOL> '<STR_LIT>' . format ( name ) , <EOL> serializer = '<STR_LIT>' , <EOL> ) </s>
