gns-deb-diff

automate the documentation of the differences between gNewSense and Debian.
git clone git://git.ricketyspace.net/gns-deb-diff.git
Log | Files | Refs

commit 32b5035c36e67926b2eb790b6df4d337baa8dc17
parent 78231eb914da59951d5cd494e9f23a54c8b179e1
Author: rsiddharth <s@ricketyspace.net>
Date:   Sat, 24 Dec 2016 22:53:16 +0000

Add function `get_args`

* gd_diff.py (get_args): New function.
* tests/tests_gd_diff.py (test_get_args_gd_diff_version)
(test_get_args): Tests for function `get_args`.

Diffstat:
gd_diff.py | 10++++++++++
tests/test_gd_diff.py | 19+++++++++++++++++++
2 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/gd_diff.py b/gd_diff.py @@ -395,3 +395,13 @@ def write_wiki_page(release, content): wd_release = wiki_page_dir(release) wp_file = os.path.join(wd_release, 'last.rev') write_file(wp_file, content) + + +def get_args(): + parser = argparse.ArgumentParser() + parser.add_argument('--version', action='version', version=__version__) + parser.add_argument('release', help='gNewSense release name') + parser.add_argument('version', help='gNewSense version number', + type=int) + + return parser.parse_args() diff --git a/tests/test_gd_diff.py b/tests/test_gd_diff.py @@ -22,6 +22,7 @@ from unittest import mock from nose.tools import * from gd_diff import * +from gns_deb_diff._version import __version__ class TestGdDiff(object): @@ -461,6 +462,24 @@ class TestGdDiff(object): assert wiki_page == gns_wiki_header() + '\n' + wiki_table + def test_get_args_gd_diff_version(self): + mock_sys_argv = ['gd-diff', '--version'] + with mock.patch('sys.stdout', new=StringIO()) as output, \ + mock.patch('sys.argv', new=mock_sys_argv): + try: + args = get_args() + except SystemExit as se: + assert_equal(__version__, output.getvalue().rstrip('\n')) + + + def test_get_args(self): + mock_sys_argv = ['gd-diff', 'parkes', '3'] + with mock.patch('sys.argv', new=mock_sys_argv): + args = get_args() + assert args.release == 'parkes' + assert args.version == 3 + + def teardown(self): """Teardown method for this class.""" if(path.exists(self.gns_pkgs_dir)):