本文整理汇总了Python中collection_json.Array类的典型用法代码示例。如果您正苦于以下问题:Python Array类的具体用法?Python Array怎么用?Python Array使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Array类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_by_rel_and_name
def test_get_by_rel_and_name(self):
foo = Link('href', rel='foo', name='bar')
bar = Link('href', rel='bar')
links = Array(Link, 'links', [foo, bar])
with self.assertRaises(ValueError):
links.get(rel='bar', name='foo')
self.assertEqual(links.get(rel='foo', name='bar'), foo)
示例2: test_get_by_name_multiple
def test_get_by_name_multiple(self):
link1 = Link('href', rel='foo', name='bar')
link2 = Link('href', rel='foo', name='bar')
links = Array(Link, 'links', [link1, link2])
self.assertEqual(links.get(name='bar'), link1)
示例3: test_get_by_name
def test_get_by_name(self):
link = Link('href', rel='foo', name='bar')
links = Array(Link, 'links', [link])
self.assertEqual(links.get(name='bar'), link)
示例4: test_get_by_rel_not_found
def test_get_by_rel_not_found(self):
link = Link('href', rel='foo')
links = Array(Link, 'links', [link])
with self.assertRaises(ValueError):
links.get(rel='bar')
示例5: test_get_by_rel
def test_get_by_rel(self):
link = Link('href', rel='foo')
links = Array(Link, 'links', [link])
self.assertEqual(links.get(rel='foo'), link)
示例6: test_find_by_rel_and_name
def test_find_by_rel_and_name(self):
foo = Link('href', rel='foo', name='bar')
bar = Link('href', rel='bar')
links = Array(Link, 'links', [foo, bar])
self.assertEqual(links.find(rel='foo', name='bar'), [foo])
self.assertEqual(links.find(rel='bar', name='foo'), [])
示例7: test_find_by_name_multiple_values
def test_find_by_name_multiple_values(self):
link1 = Link('href1', rel='foo', name='bar')
link2 = Link('href2', rel='foo', name='bar')
links = Array(Link, 'links', [link1, link2])
self.assertEqual(links.find(name='bar'), [link1, link2])
示例8: test_find_by_name_not_found
def test_find_by_name_not_found(self):
link = Link('href', rel='foo', name='bar')
links = Array(Link, 'links', [link])
self.assertEqual(links.find(name='foo'), [])
示例9: test_find_by_rel
def test_find_by_rel(self):
link = Link('href', rel='foo')
links = Array(Link, 'links', [link])
self.assertEqual(links.find(rel='foo'), [link])