def test_instantiate(self):
try:
tmpdir = mkdtemp()
tmpfile = NamedTemporaryFile('w+t', dir=tmpdir)
data = {'type': 'string'}
tmpfile.write(json.dumps(data))
tmpfile.seek(0)
# load from string
schema = JSONSchema.loads(json.dumps(data))
self.assertEqual(data, schema.attributes)
# load from readable object
schema = JSONSchema.load(tmpfile)
self.assertEqual(data, schema.attributes)
# load from file
schema = JSONSchema.loadfromfile(tmpfile.name)
self.assertEqual(data, schema.attributes)
finally:
tmpfile.close()
rmtree(tmpdir)
test_jsonschema.py 文件源码
python
阅读 59
收藏 0
点赞 0
评论 0
评论列表
文章目录