def test_match(self): p = PackageTracker() x1 = self.make_pkg("/", "=dev-libs/X-1:0") x2 = self.make_pkg("/", "=dev-libs/X-2:0") x3 = self.make_pkg("/", "=dev-libs/X-3:1") p.add_pkg(x2) p.add_pkg(x1) matches = list(p.match("/", Atom("=dev-libs/X-1"))) self.assertTrue(x1 in matches) self.assertEqual(len(matches), 1) matches = list(p.match("/", Atom("dev-libs/X"))) self.assertTrue(x1 is matches[0] and x2 is matches[1]) self.assertEqual(len(matches), 2) matches = list(p.match("/xxx", Atom("dev-libs/X"))) self.assertEqual(len(matches), 0) matches = list(p.match("/", Atom("dev-libs/Y"))) self.assertEqual(len(matches), 0) p.add_pkg(x3) matches = list(p.match("/", Atom("dev-libs/X"))) self.assertTrue(x1 is matches[0] and x2 is matches[1] and x3 is matches[2]) self.assertEqual(len(matches), 3) p.remove_pkg(x3) matches = list(p.match("/", Atom("dev-libs/X"))) self.assertTrue(x1 is matches[0] and x2 is matches[1]) self.assertEqual(len(matches), 2)