def testSuccess(self):
    data = testutils.ReadTestData("xen-xm-list-4.0.1-four-instances.txt")

    fn = testutils.CallCounter(compat.partial(self._Success, data))

    result = hv_xen._GetInstanceList(fn, True, _timeout=0.1)

    self.assertEqual(len(result), 4)

    self.assertEqual(map(compat.fst, result), [
      "Domain-0",
      "server01.example.com",
      "web3106215069.example.com",
      "testinstance.example.com",
      ])

    self.assertEqual(fn.Count(), 1)
 def testTimeout(self):
   fn = testutils.CallCounter(self._Fail)
   try:
     hv_xen._GetInstanceList(fn, False, _timeout=0.1)
   except errors.HypervisorError, err:
     self.assertTrue("timeout exceeded" in str(err))