Skip to content

Commit

Permalink
More tests and a correct exit code when tests fail!
Browse files Browse the repository at this point in the history
  • Loading branch information
mgedmin committed Sep 17, 2016
1 parent 4878c4d commit e1a8a5b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
10 changes: 4 additions & 6 deletions src/pyspacewar/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ def use_psyco():
"""Use Psyco (if available) to speed things up."""
try:
import psyco
psyco.full()
psyco.full() # pragma: nocover
except ImportError:
pass


def main():
def main(argv=None):
"""Run PySpaceWar."""
use_psyco()
ui = GameUI()
Expand Down Expand Up @@ -49,7 +49,7 @@ def main():
' note that in windowed mode the window size be 20%'
' smaller',
action='store', dest='mode')
opts, args = parser.parse_args()
opts, args = parser.parse_args(argv or sys.argv)
if opts.fullscreen is not None:
ui.fullscreen = opts.fullscreen
if opts.debug is not None:
Expand All @@ -63,9 +63,7 @@ def main():
w, h = opts.mode.split('x')
ui.fullscreen_mode = int(w), int(h)
except ValueError:
print >> sys.stderr, ('pyspacewar: error: invalid mode: %s'
% opts.mode)
sys.exit(1)
sys.exit('pyspacewar: error: invalid mode: %s' % opts.mode)
ui.init()
try:
while True:
Expand Down
3 changes: 2 additions & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ def main():
module = __import__('pyspacewar.tests.' + name, {}, {}, ('',))
suite.addTest(module.test_suite())
runner = unittest.TextTestRunner(verbosity=1)
runner.run(suite)
result = runner.run(suite)
sys.exit(not result.wasSuccessful())


if __name__ == '__main__':
Expand Down

0 comments on commit e1a8a5b

Please sign in to comment.