示例#1
0
 def check(self, container):
     container = core.SerialContainer()
     container.add(stages.CurrentState("1"))
     container.add(stages.CurrentState("2"))
     container.add(stages.CurrentState("3"))
     with self.assertRaises(IndexError):
         container["unknown"]
     child = container["2"]
     self.assertEqual(child.name, "2")
     self.assertEqual([child.name for child in container], ["1", "2", "3"])
示例#2
0
    def test(self):
        task = core.Task()
        self.assertEqual(task.id, "")
        task = core.Task("foo", core.SerialContainer())
        self.assertEqual(task.id, "foo")
        task = core.Task("task")
        self.assertEqual(task.id, "task")

        current = stages.CurrentState("current")
        self.assertEqual(current.name, "current")
        current.timeout = 1.23
        self.assertEqual(current.timeout, 1.23)

        task.add(current)

        # ownership of current was passed to task
        with self.assertRaises(TypeError):
            current.name

        task.add(stages.Connect("connect", []))
        task.add(stages.FixedState())
示例#3
0
 def test_serial(self):
     self.check(core.SerialContainer())
示例#4
0
 def test_move(self):
     container = core.SerialContainer()
     stage = stages.CurrentState()
     container.add(stage)
     with self.assertRaises(TypeError):
         stage.name