diff --git a/salve/cli/__init__.py b/salve/cli/__init__.py index 5ca9140..92b2a3b 100644 --- a/salve/cli/__init__.py +++ b/salve/cli/__init__.py @@ -18,6 +18,6 @@ def main(): import sys if sys.version_info < (2, 6): - sys.exit(1) + sys.exit('Python Version Too Old! SALVE Requires Python >= 2.6') run() diff --git a/tests/end2end/cli/common.py b/tests/end2end/cli/common.py index 0051fe5..b83a4c6 100644 --- a/tests/end2end/cli/common.py +++ b/tests/end2end/cli/common.py @@ -2,14 +2,14 @@ import mock -import tests.utils.scratch -import salve.cli +from tests.utils import scratch +from salve import cli -class RunScratchContainer(tests.utils.scratch.ScratchContainer): +class RunScratchContainer(scratch.ScratchContainer): def run_on_args(self, argv): with mock.patch('sys.argv', argv): - return salve.cli.run() + return cli.main() def run_on_manifest(self, manifest): man_path = self.get_fullname(manifest) diff --git a/tests/unit/cli/run_test.py b/tests/unit/cli/run_test.py index 783df7b..c9fb5c3 100644 --- a/tests/unit/cli/run_test.py +++ b/tests/unit/cli/run_test.py @@ -4,6 +4,7 @@ from nose.tools import istest from salve import cli +from tests.utils.exceptions import ensure_except @istest @@ -15,13 +16,21 @@ def run_on_backup_subcommand(): """ fake_argv = ['./salve.py', 'backup', '-f', 'a/b/c', '-r'] - log = {'main': False} - - def fake_main(args): - log['main'] = True + fake_main = mock.Mock() with mock.patch('sys.argv', fake_argv): with mock.patch('salve.cli.backup.main', fake_main): - cli.run() + cli.main() + + assert fake_main.called - assert log['main'] + +@istest +def old_python_version_errors(): + """ + Unit: Run On Python < 2.5 Exits + Verifies that running on arguments starting with "backup" correctly invokes + the backup main method. + """ + with mock.patch('sys.version_info', (2, 5)): + ensure_except(SystemExit, cli.main)