Skip to content

Commit

Permalink
Merge 2d1c003 into 0b2956d
Browse files Browse the repository at this point in the history
  • Loading branch information
GhostofGoes committed Mar 7, 2020
2 parents 0b2956d + 2d1c003 commit 37923a2
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Changelog
0.42 (unreleased)
-----------------

- Nothing changed yet.
- Added ``-q``/``--quiet`` command line argument. This will reduce the verbosity
of informational output, e.g. for use in a CI pipeline.


0.41 (2020-02-25)
Expand Down
15 changes: 12 additions & 3 deletions check_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class Failure(Exception):
#

VERBOSE = False
QUIET = False

_to_be_continued = False
def _check_tbc():
Expand All @@ -69,6 +70,8 @@ def _check_tbc():


def info(message):
if QUIET:
return
_check_tbc()
print(message)

Expand Down Expand Up @@ -994,8 +997,10 @@ def main():
help='location for the source tree')
parser.add_argument('--version', action='version',
version='%(prog)s version ' + __version__)
parser.add_argument('-v', '--verbose', action='store_true',
help='more verbose output')
parser.add_argument('-q', '--quiet', action='store_const', dest='quiet',
const=0, default=1, help='reduced output verbosity')
parser.add_argument('-v', '--verbose', action='store_const', dest='verbose',
const=1, default=0, help='more verbose output')
parser.add_argument('-c', '--create', action='store_true',
help='create a MANIFEST.in if missing')
parser.add_argument('-u', '--update', action='store_true',
Expand All @@ -1016,9 +1021,13 @@ def main():
if args.ignore_bad_ideas:
IGNORE_BAD_IDEAS.extend(args.ignore_bad_ideas.split(','))

if args.verbose:
verbosity = args.quiet + args.verbose
if verbosity >= 2:
global VERBOSE
VERBOSE = True
if not verbosity:
global QUIET
QUIET = True

try:
if not check_manifest(args.source_tree, create=args.create,
Expand Down
36 changes: 36 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,34 @@ def test_ignore_bad_ideas_args(self):
self.assertEqual(check_manifest.IGNORE_BAD_IDEAS,
['x', 'y', 'z'])

def test_verbose_arg(self):
import check_manifest
check_manifest.VERBOSE = False
sys.argv.append('--verbose')
check_manifest.main()
self.assertTrue(check_manifest.VERBOSE)
check_manifest.VERBOSE = False

def test_quiet_arg(self):
import check_manifest
check_manifest.QUIET = False
sys.argv.append('--quiet')
check_manifest.main()
self.assertTrue(check_manifest.QUIET)
check_manifest.QUIET = False

def test_verbose_and_quiet_arg(self):
import check_manifest
check_manifest.VERBOSE = False
check_manifest.QUIET = False
sys.argv.append('--verbose')
sys.argv.append('--quiet')
check_manifest.main()
self.assertFalse(check_manifest.VERBOSE)
self.assertFalse(check_manifest.QUIET)
check_manifest.VERBOSE = False
check_manifest.QUIET = False


class TestZestIntegration(unittest.TestCase):

Expand Down Expand Up @@ -1299,6 +1327,14 @@ def test_info_verbose(self):
self.assertEqual(sys.stdout.getvalue(),
"Reticulating splines\n")

def test_info_quiet(self):
import check_manifest
check_manifest.VERBOSE = False
check_manifest.QUIET = True
check_manifest.info("Reticulating splines")
self.assertEqual(sys.stdout.getvalue(), "")
check_manifest.QUIET = False

def test_info_begin_continue_end(self):
import check_manifest
check_manifest.VERBOSE = False
Expand Down

0 comments on commit 37923a2

Please sign in to comment.