Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

itrial.py 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. # Copyright (c) Twisted Matrix Laboratories.
  2. # See LICENSE for details.
  3. """
  4. Interfaces for Trial.
  5. Maintainer: Jonathan Lange
  6. """
  7. import zope.interface as zi
  8. class ITestCase(zi.Interface):
  9. """
  10. The interface that a test case must implement in order to be used in Trial.
  11. """
  12. failureException = zi.Attribute(
  13. "The exception class that is raised by failed assertions"
  14. )
  15. def __call__(result):
  16. """
  17. Run the test. Should always do exactly the same thing as run().
  18. """
  19. def countTestCases():
  20. """
  21. Return the number of tests in this test case. Usually 1.
  22. """
  23. def id():
  24. """
  25. Return a unique identifier for the test, usually the fully-qualified
  26. Python name.
  27. """
  28. def run(result):
  29. """
  30. Run the test, storing the results in C{result}.
  31. @param result: A L{TestResult}.
  32. """
  33. def shortDescription():
  34. """
  35. Return a short description of the test.
  36. """
  37. class IReporter(zi.Interface):
  38. """
  39. I report results from a run of a test suite.
  40. """
  41. shouldStop = zi.Attribute(
  42. "A boolean indicating that this reporter would like the " "test run to stop."
  43. )
  44. testsRun = zi.Attribute(
  45. """
  46. The number of tests that seem to have been run according to this
  47. reporter.
  48. """
  49. )
  50. def startTest(method):
  51. """
  52. Report the beginning of a run of a single test method.
  53. @param method: an object that is adaptable to ITestMethod
  54. """
  55. def stopTest(method):
  56. """
  57. Report the status of a single test method
  58. @param method: an object that is adaptable to ITestMethod
  59. """
  60. def addSuccess(test):
  61. """
  62. Record that test passed.
  63. """
  64. def addError(test, error):
  65. """
  66. Record that a test has raised an unexpected exception.
  67. @param test: The test that has raised an error.
  68. @param error: The error that the test raised. It will either be a
  69. three-tuple in the style of C{sys.exc_info()} or a
  70. L{Failure<twisted.python.failure.Failure>} object.
  71. """
  72. def addFailure(test, failure):
  73. """
  74. Record that a test has failed with the given failure.
  75. @param test: The test that has failed.
  76. @param failure: The failure that the test failed with. It will
  77. either be a three-tuple in the style of C{sys.exc_info()}
  78. or a L{Failure<twisted.python.failure.Failure>} object.
  79. """
  80. def addExpectedFailure(test, failure, todo=None):
  81. """
  82. Record that the given test failed, and was expected to do so.
  83. In Twisted 15.5 and prior, C{todo} was a mandatory parameter.
  84. @type test: L{unittest.TestCase}
  85. @param test: The test which this is about.
  86. @type failure: L{failure.Failure}
  87. @param failure: The error which this test failed with.
  88. @type todo: L{unittest.Todo}
  89. @param todo: The reason for the test's TODO status. If L{None}, a
  90. generic reason is used.
  91. """
  92. def addUnexpectedSuccess(test, todo=None):
  93. """
  94. Record that the given test failed, and was expected to do so.
  95. In Twisted 15.5 and prior, C{todo} was a mandatory parameter.
  96. @type test: L{unittest.TestCase}
  97. @param test: The test which this is about.
  98. @type todo: L{unittest.Todo}
  99. @param todo: The reason for the test's TODO status. If L{None}, a
  100. generic reason is used.
  101. """
  102. def addSkip(test, reason):
  103. """
  104. Record that a test has been skipped for the given reason.
  105. @param test: The test that has been skipped.
  106. @param reason: An object that the test case has specified as the reason
  107. for skipping the test.
  108. """
  109. def wasSuccessful():
  110. """
  111. Return a boolean indicating whether all test results that were reported
  112. to this reporter were successful or not.
  113. """
  114. def done():
  115. """
  116. Called when the test run is complete.
  117. This gives the result object an opportunity to display a summary of
  118. information to the user. Once you have called C{done} on an
  119. L{IReporter} object, you should assume that the L{IReporter} object is
  120. no longer usable.
  121. """