當前位置: 首頁>>代碼示例>>Python>>正文


Python pretty_json.PrettyJSONSerializer方法代碼示例

本文整理匯總了Python中betamax_serializers.pretty_json.PrettyJSONSerializer方法的典型用法代碼示例。如果您正苦於以下問題:Python pretty_json.PrettyJSONSerializer方法的具體用法?Python pretty_json.PrettyJSONSerializer怎麽用?Python pretty_json.PrettyJSONSerializer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在betamax_serializers.pretty_json的用法示例。


在下文中一共展示了pretty_json.PrettyJSONSerializer方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: configure

# 需要導入模塊: from betamax_serializers import pretty_json [as 別名]
# 或者: from betamax_serializers.pretty_json import PrettyJSONSerializer [as 別名]
def configure(self):
        self.r = praw.Reddit(
            user_agent="Tests for BernardJOrtcutt - [email protected]")
        placeholders = {
            x: getattr(self.r.config, x)
            for x in ("client_id client_secret username password "
                      "user_agent").split()}
        placeholders['basic_auth'] = b64_string(
            '{}:{}'.format(placeholders['client_id'],
                           placeholders['client_secret']))
        betamax.Betamax.register_serializer(pretty_json.PrettyJSONSerializer)
        with betamax.Betamax.configure() as config:
            config.cassette_library_dir = 'tests/integration/cassettes'
            config.default_cassette_options['serialize_with'] = 'prettyjson'
            config.before_record(callback=filter_access_token)
            for key, value in placeholders.items():
                if key == 'password':
                    value = quote_plus(value)
                config.define_cassette_placeholder('<{}>'.format(key.upper()),
                                                   value)

        self.subreddit = self.r.subreddit('thirdrealm')
        self.db = sqlite3.connect(':memory:')
        self.db.row_factory = sqlite3.Row
        self.cur = self.db.cursor()
        with open('create_tables.sql') as f:
            command = f.read()
        self.db.executescript(command) 
開發者ID:leviroth,項目名稱:bernard,代碼行數:30,代碼來源:helper.py

示例2: setUpClass

# 需要導入模塊: from betamax_serializers import pretty_json [as 別名]
# 或者: from betamax_serializers.pretty_json import PrettyJSONSerializer [as 別名]
def setUpClass(cls):
        cls.jenkins = DJenkins(url='http://admin:[email protected]:8080')
        betamaxopts = {'serialize_with': 'prettyjson',
                       'record_mode': 'once',
                       'match_requests_on': ['uri', 'method', 'body', 'headers']}
        cassettedir = os.path.join(cls.basefolder, 'cassettes')
        cls.recorder = Betamax(session=cls.jenkins.session, cassette_library_dir=cassettedir,
                               default_cassette_options=betamaxopts)
        cls.recorder.register_serializer(pretty_json.PrettyJSONSerializer) 
開發者ID:ordjinnization,項目名稱:djinn,代碼行數:11,代碼來源:test_djenkins.py


注:本文中的betamax_serializers.pretty_json.PrettyJSONSerializer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。