diff --git a/src/pyspacewar/main.py b/src/pyspacewar/main.py index e42111f..b8c9b5d 100644 --- a/src/pyspacewar/main.py +++ b/src/pyspacewar/main.py @@ -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() @@ -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: @@ -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: diff --git a/test.py b/test.py index 813b38c..f3360ba 100755 --- a/test.py +++ b/test.py @@ -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__':