本文整理汇总了Python中pants.goal.products.UnionProducts.get_for_target方法的典型用法代码示例。如果您正苦于以下问题:Python UnionProducts.get_for_target方法的具体用法?Python UnionProducts.get_for_target怎么用?Python UnionProducts.get_for_target使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pants.goal.products.UnionProducts
的用法示例。
在下文中一共展示了UnionProducts.get_for_target方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: UnionProductsTest
# 需要导入模块: from pants.goal.products import UnionProducts [as 别名]
# 或者: from pants.goal.products.UnionProducts import get_for_target [as 别名]
class UnionProductsTest(BaseTest):
def setUp(self):
super(UnionProductsTest, self).setUp()
self.products = UnionProducts()
def test_get_for_target(self):
c = self.make_target('c')
b = self.make_target('b', dependencies=[c])
a = self.make_target('a', dependencies=[b, c])
self.products.add_for_target(a, [1])
self.products.add_for_target(b, [2])
self.products.add_for_target(c, [3])
self.assertEquals(self.products.get_for_target(a), OrderedSet([1, 2, 3]))
self.assertEquals(self.products.get_for_target(b), OrderedSet([2, 3]))
self.assertEquals(self.products.get_for_target(c), OrderedSet([3]))
def test_empty_products(self):
c = self.make_target('c')
self.assertFalse(self.products.get_for_target(c))
def test_non_empty_products(self):
c = self.make_target('c')
self.products.add_for_target(c, [3])
self.assertTrue(self.products.get_for_target(c))
示例2: UnionProductsTest
# 需要导入模块: from pants.goal.products import UnionProducts [as 别名]
# 或者: from pants.goal.products.UnionProducts import get_for_target [as 别名]
class UnionProductsTest(BaseTest):
def setUp(self):
super(UnionProductsTest, self).setUp()
self.products = UnionProducts()
def test_get_for_target(self):
c = self.make_target("c")
b = self.make_target("b", dependencies=[c])
a = self.make_target("a", dependencies=[b, c])
self.products.add_for_target(a, [1])
self.products.add_for_target(b, [2])
self.products.add_for_target(c, [3])
self.assertEquals(self.products.get_for_target(a), OrderedSet([1, 2, 3]))
self.assertEquals(self.products.get_for_target(b), OrderedSet([2, 3]))
self.assertEquals(self.products.get_for_target(c), OrderedSet([3]))
self.assertEquals(self.products.get_for_target(a, transitive=False), OrderedSet([1]))
self.assertEquals(self.products.get_for_target(b, transitive=False), OrderedSet([2]))
self.assertEquals(self.products.get_for_target(c, transitive=False), OrderedSet([3]))
def test_remove_for_target(self):
c = self.make_target("c")
b = self.make_target("b", dependencies=[c])
a = self.make_target("a", dependencies=[b, c])
self.products.add_for_target(a, [1])
self.products.add_for_target(b, [2])
self.products.add_for_target(c, [3])
self.products.remove_for_target(a, [1])
self.assertEquals(self.products.get_for_target(a), OrderedSet([2, 3]))
self.assertEquals(self.products.get_for_target(b), OrderedSet([2, 3]))
self.assertEquals(self.products.get_for_target(c), OrderedSet([3]))
def test_empty_products(self):
c = self.make_target("c")
self.assertFalse(self.products.get_for_target(c))
def test_non_empty_products(self):
c = self.make_target("c")
self.products.add_for_target(c, [3])
self.assertTrue(self.products.get_for_target(c))
def test_target_for_product_existing_product(self):
c = self.make_target("c")
self.products.add_for_target(c, [3])
found_target = self.products.target_for_product(3)
self.assertEqual(c, found_target)
def test_target_for_product_nonexistent_product(self):
c = self.make_target("c")
self.products.add_for_target(c, [3])
found_target = self.products.target_for_product(1000)
self.assertIsNone(found_target)
示例3: UnionProductsTest
# 需要导入模块: from pants.goal.products import UnionProducts [as 别名]
# 或者: from pants.goal.products.UnionProducts import get_for_target [as 别名]
class UnionProductsTest(BaseTest):
def setUp(self):
super(UnionProductsTest, self).setUp()
self.products = UnionProducts()
def test_get_for_target(self):
c = self.make_target('c')
b = self.make_target('b', dependencies=[c])
a = self.make_target('a', dependencies=[b, c])
self.products.add_for_target(a, [1])
self.products.add_for_target(b, [2])
self.products.add_for_target(c, [3])
self.assertEquals(self.products.get_for_targets(a.closure(bfs=True)), OrderedSet([1, 2, 3]))
self.assertEquals(self.products.get_for_targets(b.closure(bfs=True)), OrderedSet([2, 3]))
self.assertEquals(self.products.get_for_targets(c.closure(bfs=True)), OrderedSet([3]))
self.assertEquals(self.products.get_for_target(a), OrderedSet([1]))
self.assertEquals(self.products.get_for_target(b), OrderedSet([2]))
self.assertEquals(self.products.get_for_target(c), OrderedSet([3]))
def test_get_product_target_mappings_for_targets(self):
b = self.make_target('b')
a = self.make_target('a', dependencies=[b])
self.products.add_for_target(a, [1, 3])
self.products.add_for_target(b, [2, 3])
self.assertEquals(self.products.get_for_targets(a.closure(bfs=True)), OrderedSet([1, 3, 2]))
self.assertEquals(self.products.get_for_targets(b.closure(bfs=True)), OrderedSet([2, 3]))
self.assertEquals(self.products.get_product_target_mappings_for_targets(a.closure(bfs=True)),
[(1, a), (3, a), (2, b), (3, b)])
def test_copy(self):
c = self.make_target('c')
b = self.make_target('b', dependencies=[c])
a = self.make_target('a', dependencies=[b, c])
self.products.add_for_target(a, [1])
self.products.add_for_target(b, [2])
copied = self.products.copy()
self.assertEquals(self.products.get_for_targets(a.closure(bfs=True)), OrderedSet([1, 2]))
self.assertEquals(self.products.get_for_targets(b.closure(bfs=True)), OrderedSet([2]))
self.assertEquals(copied.get_for_targets(a.closure(bfs=True)), OrderedSet([1, 2]))
self.assertEquals(copied.get_for_targets(b.closure(bfs=True)), OrderedSet([2]))
copied.add_for_target(c, [3])
self.assertEquals(self.products.get_for_targets(a.closure(bfs=True)), OrderedSet([1, 2]))
self.assertEquals(self.products.get_for_targets(b.closure(bfs=True)), OrderedSet([2]))
self.assertEquals(self.products.get_for_targets(c.closure(bfs=True)), OrderedSet())
self.assertEquals(copied.get_for_targets(a.closure(bfs=True)), OrderedSet([1, 2, 3]))
self.assertEquals(copied.get_for_targets(b.closure(bfs=True)), OrderedSet([2, 3]))
self.assertEquals(copied.get_for_targets(c.closure(bfs=True)), OrderedSet([3]))
def test_remove_for_target(self):
c = self.make_target('c')
b = self.make_target('b', dependencies=[c])
a = self.make_target('a', dependencies=[b, c])
self.products.add_for_target(a, [1])
self.products.add_for_target(b, [2])
self.products.add_for_target(c, [3])
self.products.remove_for_target(a, [1])
self.assertEquals(self.products.get_for_targets(a.closure(bfs=True)), OrderedSet([2, 3]))
self.assertEquals(self.products.get_for_targets(b.closure(bfs=True)), OrderedSet([2, 3]))
self.assertEquals(self.products.get_for_targets(c.closure(bfs=True)), OrderedSet([3]))
def test_empty_products(self):
c = self.make_target('c')
self.assertFalse(self.products.get_for_target(c))
def test_non_empty_products(self):
c = self.make_target('c')
self.products.add_for_target(c, [3])
self.assertTrue(self.products.get_for_target(c))
def test_target_for_product_existing_product(self):
c = self.make_target('c')
self.products.add_for_target(c, [3])
found_target = self.products.target_for_product(3)
self.assertEqual(c, found_target)
def test_target_for_product_nonexistent_product(self):
c = self.make_target('c')
self.products.add_for_target(c, [3])
found_target = self.products.target_for_product(1000)
self.assertIsNone(found_target)