<s> import os <EOL> import json <EOL> import pytest <EOL> import vcr <EOL> from six . moves . urllib . request import urlopen <EOL> def test_set_serializer_default_config ( tmpdir ) : <EOL> my_vcr = vcr . VCR ( serializer = '<STR_LIT>' ) <EOL> with my_vcr . use_cassette ( str ( tmpdir . join ( '<STR_LIT>' ) ) ) : <EOL> assert my_vcr . serializer == '<STR_LIT>' <EOL> urlopen ( '<STR_LIT>' ) <EOL> with open ( str ( tmpdir . join ( '<STR_LIT>' ) ) ) as f : <EOL> assert json . loads ( f . read ( ) ) <EOL> def test_default_set_cassette_library_dir ( tmpdir ) : <EOL> my_vcr = vcr . VCR ( cassette_library_dir = str ( tmpdir . join ( '<STR_LIT>' ) ) ) <EOL> with my_vcr . use_cassette ( '<STR_LIT>' ) : <EOL> urlopen ( '<STR_LIT>' ) <EOL> assert os . path . exists ( str ( tmpdir . join ( '<STR_LIT>' ) . join ( '<STR_LIT>' ) ) ) <EOL> def test_override_set_cassette_library_dir ( tmpdir ) : <EOL> my_vcr = vcr . VCR ( cassette_library_dir = str ( tmpdir . join ( '<STR_LIT>' ) ) ) <EOL> cld = str ( tmpdir . join ( '<STR_LIT>' ) ) <EOL> with my_vcr . use_cassette ( '<STR_LIT>' , cassette_library_dir = cld ) : <EOL> urlopen ( '<STR_LIT>' ) <EOL> assert os . path . exists ( str ( tmpdir . join ( '<STR_LIT>' ) . join ( '<STR_LIT>' ) ) ) <EOL> assert not os . path . exists ( str ( tmpdir . join ( '<STR_LIT>' ) . join ( '<STR_LIT>' ) ) ) <EOL> def test_override_match_on ( tmpdir ) : <EOL> my_vcr = vcr . VCR ( match_on = [ '<STR_LIT>' ] ) <EOL> with my_vcr . use_cassette ( str ( tmpdir . join ( '<STR_LIT>' ) ) ) : <EOL> urlopen ( '<STR_LIT>' ) <EOL> with my_vcr . use_cassette ( str ( tmpdir . join ( '<STR_LIT>' ) ) ) as cass : <EOL> urlopen ( '<STR_LIT>' ) <EOL> assert len ( cass ) == <NUM_LIT:1> <EOL> assert cass . play_count == <NUM_LIT:1> <EOL> def test_missing_matcher ( ) : <EOL> my_vcr = vcr . VCR ( ) <EOL> my_vcr . register_matcher ( "<STR_LIT>" , object ) <EOL> with pytest . raises ( KeyError ) : <EOL> with my_vcr . use_cassette ( "<STR_LIT>" , match_on = [ '<STR_LIT>' ] ) : <EOL> pass </s>
