本文整理匯總了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, ())),
)
示例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, ())})
示例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()