def testCalculateRuleSequence(self):
    graph = RuleGraph(self.project)

    with self.assertRaises(KeyError):
      graph.calculate_rule_sequence(':x')
    with self.assertRaises(KeyError):
      graph.calculate_rule_sequence([':x'])
    with self.assertRaises(KeyError):
      graph.calculate_rule_sequence(['m1:x'])

    seq = graph.calculate_rule_sequence('m1:a1')
    self.assertEqual(len(seq), 1)
    self.assertEqual(seq[0].name, 'a1')
    seq = graph.calculate_rule_sequence(['m1:a1'])
    self.assertEqual(len(seq), 1)
    self.assertEqual(seq[0].name, 'a1')

    seq = graph.calculate_rule_sequence(['m1:b'])
    self.assertEqual(len(seq), 3)
    self.assertTrue((seq[0].name in ['a1', 'a2']) or
                    (seq[1].name in ['a1', 'a2']))
    self.assertEqual(seq[2].name, 'b')

    seq = graph.calculate_rule_sequence(['m1:a1', 'm1:b'])
    self.assertEqual(len(seq), 3)
    self.assertTrue((seq[0].name in ['a1', 'a2']) or
                    (['a1', 'a2'] in seq[1].name))
    self.assertEqual(seq[2].name, 'b')

    seq = graph.calculate_rule_sequence(['m1:a1', 'm1:a3'])
    self.assertEqual(len(seq), 2)
    self.assertTrue((seq[0].name in ['a1', 'a3']) or
                    (seq[1].name in ['a1', 'a3']))

    module = Module('mx', rules=[Rule('a', deps=[':b'])])
    project = Project(modules=[module])
    graph = RuleGraph(project)
    with self.assertRaises(KeyError):
      graph.calculate_rule_sequence('mx:a')
dataset/ETHPy150Open google/anvil-build/anvil/graph_test.py/RuleGraphTest.testCalculateRuleSequence/swapped operands of `in`