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


Python FormatChecker.cls_checks方法代碼示例

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


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

示例1: test_it_can_register_cls_checkers

# 需要導入模塊: from jsonschema import FormatChecker [as 別名]
# 或者: from jsonschema.FormatChecker import cls_checks [as 別名]
 def test_it_can_register_cls_checkers(self):
     original = dict(FormatChecker.checkers)
     self.addCleanup(FormatChecker.checkers.pop, "boom")
     FormatChecker.cls_checks("boom")(boom)
     self.assertEqual(
         FormatChecker.checkers,
         dict(original, boom=(boom, ())),
     )
開發者ID:Julian,項目名稱:jsonschema,代碼行數:10,代碼來源:test_format.py

示例2: test_it_can_register_cls_checkers

# 需要導入模塊: from jsonschema import FormatChecker [as 別名]
# 或者: from jsonschema.FormatChecker import cls_checks [as 別名]
 def test_it_can_register_cls_checkers(self):
     with mock.patch.dict(FormatChecker.checkers, clear=True):
         FormatChecker.cls_checks("new")(self.fn)
         self.assertEqual(FormatChecker.checkers, {"new": (self.fn, ())})
開發者ID:BarnetteME1,項目名稱:DnD-stuff,代碼行數:6,代碼來源:test_format.py

示例3: validate_timestamp

# 需要導入模塊: from jsonschema import FormatChecker [as 別名]
# 或者: from jsonschema.FormatChecker import cls_checks [as 別名]
        for trace in trace_seq:
            validate_timestamp(trace['timestamp'])
    # FIXME: Be more specific with errors.
    except Exception as e:
        print(e)
        abort(400)

    try:
        for trace in trace_seq:
            # FIXME: If not unique timestamp, it's a user error 400.
            write_trace_in_db(session_id, trace)
        # FIXME: Or 200, as the resource is not shown to user?
        return make_response(jsonify({"status": "OK"}), 201)
    except Exception as e:
        print(e)
        abort(500)



# Adds date-time checking.
# FIXME: Is this really how it's supposed to be done?
FormatChecker.cls_checks("date-time", ())(validate_rfc3339)

json_schema = open_json_schema()



if __name__ == "__main__":
    app.run()
開發者ID:HSLdevcom,項目名稱:navigator-recorder,代碼行數:31,代碼來源:navirec.py


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