-
Notifications
You must be signed in to change notification settings - Fork 1
/
pong.py
50 lines (37 loc) · 1.1 KB
/
pong.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import sys
import optparse
import unittest
from game import GameMaker
import guitests
import movingtests
import detector
parser = optparse.OptionParser()
parser.add_option("-t", "--test", action="store_true")
def main():
gameMaker = GameMaker()
game = gameMaker()
game.start()
def test():
loader = unittest.TestLoader()
detectorTests = loader.loadTestsFromTestCase(
detector.DetectorTests)
guiTests = loader.loadTestsFromTestCase(
guitests.GuiTests)
movingTests = loader.loadTestsFromTestCase(
movingtests.MovingTests)
allTests = unittest.TestSuite([detectorTests,
guiTests,
movingTests
])
runner = unittest.TextTestRunner()
result = runner.run(allTests)
if not result.wasSuccessful():
sys.exit(1)
if __name__ == '__main__':
options, args = parser.parse_args()
#this is needed for the unit tests to not get confused:
del sys.argv[1:]
if options.test:
test()
else:
main()