def testTroveSourceStack(self):
        # Test the behaviour of TroveSourceStack instances

        s1 = SimplestFindTroveSource()
        s2 = SimplestFindTroveSource()
        s3 = SimplestFindTroveSource()

        nodeps = deps.parseFlavor('')

        count = 3

        names = []
        versions = []
        for v in range(count):
            sv = str(v + 1)
            versions.append(ThawVersion('/localhost@rpl:devel/%s:1.0-1-1' % sv))
            names.append("test%s" % sv)

        # Generate troves
        t = []
        for i in range(count):
            l = []
            t.append(l)
            name = names[i]
            for j in range(count):
                l.append((name, versions[j], nodeps))

        s1.addTroves(t[0][1])
        s2.addTroves(t[0][0], t[1][1])
        s3.addTroves(t[0][2], t[1][0], t[2][2])

        # Catch an early bug with a bad index
        try:
            ts1 = stack(s1)
        except Exception, e:
            # No exception expected
            self.fail(e % "Caught exception: %s")
        # The implementation of stack says so...
        self.assertEqual(ts1, s1)

        ret = ts1.hasTroves([t[0][0], t[1][1], t[2][2]])
        self.assertEqual(ret, [True, False, False])

        ts2 = stack(ts1)
        ret = ts1.hasTroves([t[0][2], t[1][0], t[2][1]])
        self.assertEqual(ret, [True, False, False])

        ts3 = stack(s1, s3)
        ts4 = stack(s2, ts3)
        # Same deal, but use the constructor for TroveSourceStack
        ts5 = TroveSourceStack(s2, ts3)

        for s in [s1, s2, s3]:
            self.assertTrue(ts4.hasSource(s))
            self.assertTrue(ts5.hasSource(s))

        for (rs, es) in zip(ts4.iterSources(), [s2, s1, s3]):
            self.assertEqual(rs, es)

        for (rs, es) in zip(ts5.iterSources(), [s2, s1, s3]):
            self.assertEqual(rs, es)

        # same source specified twice - obtain a stack
        ts6 = stack(s1, s1)
        self.assertNotEqual(ts6, s1)
        self.assertTrue(isinstance(ts6, TroveSourceStack))

        ts7 = stack(ts6, ts6)
        self.assertEqual(ts7, ts6)

        ts8 = stack(ts3, ts4)
        # Old implementation was adding ts4 as a source for ts3, instead of
        # adding the subsources of ts4 to ts3
        for s in ts8.iterSources():
            self.assertFalse(isinstance(s, TroveSourceStack))
dataset/ETHPy150Open sassoftware/conary/conary_test/repositorytest/trovesourcetest.py/ChangesetFilesTest.testTroveSourceStack/swapped operands of `%`