def testGetActivityForResourceWithExtensions(self):
     result = ResultWithResourceExtensions()
     resource_manager = MockResource()
     r = resource_manager.getResource(result)
     expected = [("make", "start", resource_manager),
                 ("make", "stop", resource_manager)]
     resource_manager.finishedWith(r)
     self.assertEqual(expected, result._calls)
 def testResultPassedToResources(self):
     resource_manager = MakeCounter()
     test_case = self.makeTestCase(lambda x: None)
     test_case.resources = [('_default', resource_manager)]
     self.optimising_suite.addTest(test_case)
     result = ResultWithResourceExtensions()
     self.optimising_suite.run(result)
     # We should see the resource made and cleaned once. As its not a
     # resource aware test, it won't make any calls itself.
     self.assertEqual(4, len(result._calls))
 def testResetActivityForResourceWithExtensions(self):
     result = ResultWithResourceExtensions()
     resource_manager = MockResource()
     expected = [
         ("reset", "start", resource_manager),
         ("reset", "stop", resource_manager),
     ]
     resource_manager.getResource()
     r = resource_manager.getResource()
     resource_manager.dirtied(r)
     resource_manager.finishedWith(r)
     r = resource_manager.getResource(result)
     resource_manager.dirtied(r)
     resource_manager.finishedWith(r)
     resource_manager.finishedWith(resource_manager._currentResource)
     self.assertEqual(expected, result._calls)
 def testResultPassedToResources(self):
     result = ResultWithResourceExtensions()
     self.resourced_case.resources = [("foo", self.resource_manager)]
     self.resourced_case.run(result)
     self.assertEqual(4, len(result._calls))