From 3ce74c7c29e5600df3cc3aacb6f312d06ef4b1e5 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Fri, 17 Aug 2012 19:40:13 +0100 Subject: [PATCH] Fixed Python 3 whitespace error in 0alias Also, added unit-tests for this. --- 0alias | 2 +- tests/testlaunch.py | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/0alias b/0alias index faac6b0..0f5a217 100755 --- a/0alias +++ b/0alias @@ -173,7 +173,7 @@ if options.manpage: if manpage_file.endswith('.1') or \ manpage_file.endswith('.6') or \ manpage_file.endswith('.8'): - manpage_prog = manpage_file[:-2] + manpage_prog = manpage_file[:-2] if manpage_prog == prog_name or manpage_prog == alias_name: os.execlp('man', 'man', os.path.join(root, f)) sys.exit(1) diff --git a/tests/testlaunch.py b/tests/testlaunch.py index 21e300d..952f82a 100755 --- a/tests/testlaunch.py +++ b/tests/testlaunch.py @@ -3,7 +3,7 @@ from __future__ import print_function from basetest import BaseTest, StringIO, BytesIO -import sys, tempfile, os +import sys, tempfile, os, imp import unittest import logging @@ -232,5 +232,29 @@ class TestLaunch(BaseTest): self.assertEqual("", err) assert 'Local.xml' in out, out + def testExecutables(self): + # Check top-level scripts are readable (detects white-space errors) + for script in ['0launch', '0alias', '0store', '0desktop', '0install']: + path = os.path.join('..', script) + + old_stdout = sys.stdout + old_stderr = sys.stderr + old_argv = sys.argv + try: + sys.argv = [script, '--help'] + sys.stderr = sys.stdout = StringIO() + + imp.load_source(script, path) + except SystemExit as ex: + out = sys.stdout.getvalue() + assert 'Usage: ' in out, (script, out) + else: + assert False + finally: + sys.stdout = old_stdout + sys.stderr = old_stderr + sys.argv = old_argv + + if __name__ == '__main__': unittest.main() -- 2.11.4.GIT