diff options
author | Mike Frysinger <vapier@gentoo.org> | 2017-03-07 16:04:15 -0800 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2017-03-07 16:04:15 -0800 |
commit | 4759a27d5fd878b59201fb48233e066eccf03be2 (patch) | |
tree | 2de9ef9336811cb70f9ec30603a4dc24a01f28e2 | |
parent | ekeyword: enable bad-whitespace check (diff) | |
download | gentoolkit-4759a27d5fd878b59201fb48233e066eccf03be2.tar.gz gentoolkit-4759a27d5fd878b59201fb48233e066eccf03be2.tar.bz2 gentoolkit-4759a27d5fd878b59201fb48233e066eccf03be2.zip |
ekeyword: misc source touchups
No functional changes here!
-rwxr-xr-x | src/ekeyword/ekeyword.py | 8 | ||||
-rwxr-xr-x | src/ekeyword/ekeyword_unittest.py | 7 |
2 files changed, 13 insertions, 2 deletions
diff --git a/src/ekeyword/ekeyword.py b/src/ekeyword/ekeyword.py index 56e284b..6d09001 100755 --- a/src/ekeyword/ekeyword.py +++ b/src/ekeyword/ekeyword.py @@ -99,6 +99,10 @@ def sort_keywords(arches): keywords.append(g) def arch_key(keyword): + """Callback for python sorting functions + + Used to turn a Gentoo keyword into a sortable form. + """ # Sort independent of leading marker (~ or -). arch = keyword_to_arch(keyword) @@ -306,8 +310,8 @@ def process_ebuild(ebuild, ops, arch_status=None, verbose=0, quiet=0, dry_run: Do not make any changes to |ebuild|; show what would be done style: The diff style - Returns: - Whether any updates were processed + Returns: + Whether any updates were processed """ with io.open(ebuild, encoding='utf8') as f: updated, content = process_content( diff --git a/src/ekeyword/ekeyword_unittest.py b/src/ekeyword/ekeyword_unittest.py index be84cc1..3465dfb 100755 --- a/src/ekeyword/ekeyword_unittest.py +++ b/src/ekeyword/ekeyword_unittest.py @@ -7,6 +7,8 @@ """Unittests for ekeyword""" +from __future__ import print_function + import os import tempfile import unittest @@ -21,14 +23,17 @@ class TestSortKeywords(unittest.TestCase): """Tests for sort_keywords""" def _test(self, input_data, exp_data): + """Sort |input_data| and make sure it matches |exp_data|""" output_data = ekeyword.sort_keywords(input_data.split()) self.assertEqual(exp_data.split(), output_data) def testNull(self): + """Verify whitespace is collapsed""" self._test('', '') self._test(' ', '') def testGlob(self): + """Verify globs get sorted before all others""" self._test('* arm', '* arm') self._test('arm -* x86', '-* arm x86') self._test('hppa ~* amd64', '~* amd64 hppa') @@ -356,6 +361,7 @@ class TestLoadProfileData(unittest.TestCase): class TestArgToOps(unittest.TestCase): + """Tests for arg_to_op()""" def _test(self, arg, op): self.assertEqual(ekeyword.arg_to_op(arg), ekeyword.Op(*op)) @@ -377,6 +383,7 @@ class TestArgToOps(unittest.TestCase): class TestMain(unittest.TestCase): + """Tests for the main entry point""" def testSmoke(self): ekeyword.main(['arm', '--dry-run', os.path.join(TESTDIR, 'process-1.ebuild')]) |