/usr/lib/python2.7/dist-packages/betamax/configure.py is in python-betamax 0.5.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | from .cassette import Cassette
class Configuration(object):
"""This object acts as a proxy to configure different parts of Betamax.
You should only ever encounter this object when configuring the library as
a whole. For example:
.. code::
with Betamax.configure() as config:
config.cassette_library_dir = 'tests/cassettes/'
config.default_cassette_options['record_mode'] = 'once'
config.default_cassette_options['match_requests_on'] = ['uri']
config.define_cassette_placeholder('<URI>', 'http://httpbin.org')
config.preserve_exact_body_bytes = True
"""
CASSETTE_LIBRARY_DIR = 'vcr/cassettes'
def __enter__(self):
return self
def __exit__(self, *args):
pass
def __setattr__(self, prop, value):
if prop == 'preserve_exact_body_bytes':
self.default_cassette_options[prop] = True
else:
super(Configuration, self).__setattr__(prop, value)
@property
def cassette_library_dir(self):
"""Retrieve and set the directory to store the cassettes in."""
return Configuration.CASSETTE_LIBRARY_DIR
@cassette_library_dir.setter
def cassette_library_dir(self, value):
Configuration.CASSETTE_LIBRARY_DIR = value
@property
def default_cassette_options(self):
"""Retrieve and set the default cassette options.
The options include:
- ``match_requests_on``
- ``placeholders``
- ``re_record_interval``
- ``record_mode``
- ``preserve_exact_body_bytes``
Other options will be ignored.
"""
return Cassette.default_cassette_options
@default_cassette_options.setter
def default_cassette_options(self, value):
Cassette.default_cassette_options = value
def define_cassette_placeholder(self, placeholder, replace):
"""Define a placeholder value for some text.
This also will replace the placeholder text with the text you wish it
to use when replaying interactions from cassettes.
:param str placeholder: (required), text to be used as a placeholder
:param str replace: (required), text to be replaced or replacing the
placeholder
"""
self.default_cassette_options['placeholders'].append({
'placeholder': placeholder,
'replace': replace
})
|