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.

sample.py 2.0KB

1 year ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. """This module is used by test_loader to test the Trial test loading
  2. functionality. Do NOT change the number of tests in this module. Do NOT change
  3. the names the tests in this module.
  4. """
  5. import unittest as pyunit
  6. from twisted.python.util import mergeFunctionMetadata
  7. from twisted.trial import unittest
  8. class FooTest(unittest.SynchronousTestCase):
  9. def test_foo(self):
  10. pass
  11. def test_bar(self):
  12. pass
  13. def badDecorator(fn):
  14. """
  15. Decorate a function without preserving the name of the original function.
  16. Always return a function with the same name.
  17. """
  18. def nameCollision(*args, **kwargs):
  19. return fn(*args, **kwargs)
  20. return nameCollision
  21. def goodDecorator(fn):
  22. """
  23. Decorate a function and preserve the original name.
  24. """
  25. def nameCollision(*args, **kwargs):
  26. return fn(*args, **kwargs)
  27. return mergeFunctionMetadata(fn, nameCollision)
  28. class DecorationTest(unittest.SynchronousTestCase):
  29. def test_badDecorator(self):
  30. """
  31. This test method is decorated in a way that gives it a confusing name
  32. that collides with another method.
  33. """
  34. test_badDecorator = badDecorator(test_badDecorator)
  35. def test_goodDecorator(self):
  36. """
  37. This test method is decorated in a way that preserves its name.
  38. """
  39. test_goodDecorator = goodDecorator(test_goodDecorator)
  40. def renamedDecorator(self):
  41. """
  42. This is secretly a test method and will be decorated and then renamed so
  43. test discovery can find it.
  44. """
  45. test_renamedDecorator = goodDecorator(renamedDecorator)
  46. def nameCollision(self):
  47. """
  48. This isn't a test, it's just here to collide with tests.
  49. """
  50. class PyunitTest(pyunit.TestCase):
  51. def test_foo(self):
  52. pass
  53. def test_bar(self):
  54. pass
  55. class NotATest:
  56. def test_foo(self):
  57. pass
  58. class AlphabetTest(unittest.SynchronousTestCase):
  59. def test_a(self):
  60. pass
  61. def test_b(self):
  62. pass
  63. def test_c(self):
  64. pass