From 8ddff5c74f533f4f125c957d7bd063452c59f0db Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sun, 9 Feb 2020 15:00:25 -0500 Subject: repo: add --version support to the launcher We can get version info when in a checkout, but it'd be helpful to show that info at all times. Change-Id: Ieeb44a503c9d7d8c487db4810bdcf3d5f6656c82 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254712 Reviewed-by: Michael Mortensen Reviewed-by: Mike Frysinger Tested-by: Mike Frysinger --- tests/test_wrapper.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests/test_wrapper.py') diff --git a/tests/test_wrapper.py b/tests/test_wrapper.py index e574946b..61636b26 100644 --- a/tests/test_wrapper.py +++ b/tests/test_wrapper.py @@ -26,6 +26,14 @@ from pyversion import is_python3 import wrapper +if is_python3(): + from unittest import mock + from io import StringIO +else: + import mock + from StringIO import StringIO + + def fixture(*paths): """Return a path relative to tests/fixtures. """ @@ -48,6 +56,16 @@ class RepoWrapperUnitTest(RepoWrapperTestCase): """Tests helper functions in the repo wrapper """ + def test_version(self): + """Make sure _Version works.""" + with self.assertRaises(SystemExit) as e: + with mock.patch('sys.stdout', new_callable=StringIO) as stdout: + with mock.patch('sys.stderr', new_callable=StringIO) as stderr: + self.wrapper._Version() + self.assertEqual(0, e.exception.code) + self.assertEqual('', stderr.getvalue()) + self.assertIn('repo launcher version', stdout.getvalue()) + def test_get_gitc_manifest_dir_no_gitc(self): """ Test reading a missing gitc config file -- cgit v1.2.3-54-g00ecf