__init__.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # testresources: extensions to python unittest to allow declaritive use
  2. # of resources by test cases.
  3. #
  4. # Copyright (c) 2005-2010 Testresources Contributors
  5. #
  6. # Licensed under either the Apache License, Version 2.0 or the BSD 3-clause
  7. # license at the users choice. A copy of both licenses are available in the
  8. # project source as Apache-2.0 and BSD. You may not use this file except in
  9. # compliance with one of these two licences.
  10. #
  11. # Unless required by applicable law or agreed to in writing, software distributed
  12. # under these licenses is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
  13. # CONDITIONS OF ANY KIND, either express or implied. See the license you chose
  14. # for the specific language governing permissions and limitations under that
  15. # license.
  16. #
  17. from unittest import TestResult
  18. import testresources
  19. from testresources.tests import TestUtil
  20. def test_suite():
  21. import testresources.tests.test_optimising_test_suite
  22. import testresources.tests.test_resourced_test_case
  23. import testresources.tests.test_test_loader
  24. import testresources.tests.test_test_resource
  25. import testresources.tests.test_resource_graph
  26. result = TestUtil.TestSuite()
  27. result.addTest(testresources.tests.test_test_loader.test_suite())
  28. result.addTest(testresources.tests.test_test_resource.test_suite())
  29. result.addTest(testresources.tests.test_resourced_test_case.test_suite())
  30. result.addTest(testresources.tests.test_resource_graph.test_suite())
  31. result.addTest(
  32. testresources.tests.test_optimising_test_suite.test_suite())
  33. return result
  34. class ResultWithoutResourceExtensions(object):
  35. """A test fake which does not have resource extensions."""
  36. class ResultWithResourceExtensions(TestResult):
  37. """A test fake which has resource extensions."""
  38. def __init__(self):
  39. TestResult.__init__(self)
  40. self._calls = []
  41. def startCleanResource(self, resource):
  42. self._calls.append(("clean", "start", resource))
  43. def stopCleanResource(self, resource):
  44. self._calls.append(("clean", "stop", resource))
  45. def startMakeResource(self, resource):
  46. self._calls.append(("make", "start", resource))
  47. def stopMakeResource(self, resource):
  48. self._calls.append(("make", "stop", resource))
  49. def startResetResource(self, resource):
  50. self._calls.append(("reset", "start", resource))
  51. def stopResetResource(self, resource):
  52. self._calls.append(("reset", "stop", resource))