<s> import vcr <EOL> from six . moves . urllib . request import urlopen <EOL> def true_matcher ( r1 , r2 ) : <EOL> return True <EOL> def false_matcher ( r1 , r2 ) : <EOL> return False <EOL> def test_registered_true_matcher ( tmpdir ) : <EOL> my_vcr = vcr . VCR ( ) <EOL> my_vcr . register_matcher ( '<STR_LIT:true>' , true_matcher ) <EOL> testfile = str ( tmpdir . join ( '<STR_LIT>' ) ) <EOL> with my_vcr . use_cassette ( testfile , match_on = [ '<STR_LIT:true>' ] ) : <EOL> urlopen ( '<STR_LIT>' ) <EOL> urlopen ( '<STR_LIT>' ) <EOL> with my_vcr . use_cassette ( testfile , match_on = [ '<STR_LIT:true>' ] ) : <EOL> urlopen ( '<STR_LIT>' ) <EOL> urlopen ( '<STR_LIT>' ) <EOL> def test_registered_false_matcher ( tmpdir ) : <EOL> my_vcr = vcr . VCR ( ) <EOL> my_vcr . register_matcher ( '<STR_LIT:false>' , false_matcher ) <EOL> testfile = str ( tmpdir . join ( '<STR_LIT>' ) ) <EOL> with my_vcr . use_cassette ( testfile , match_on = [ '<STR_LIT:false>' ] ) as cass : <EOL> urlopen ( '<STR_LIT>' ) <EOL> urlopen ( '<STR_LIT>' ) <EOL> assert len ( cass ) == <NUM_LIT:2> </s>
