From 1a828465784b38299de75fe0b8d54412e737a2f4 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Thu, 14 Jul 2016 22:37:35 -0600 Subject: [PATCH] cli.Config: remove common attributes The values set by the base Config constructor could mask Click parsers that weren't supplying defaults properly, or which were using different defaults. --- src/wormhole/cli/cli.py | 20 +++----------------- src/wormhole/test/test_args.py | 3 --- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/src/wormhole/cli/cli.py b/src/wormhole/cli/cli.py index 5c58c76..f6bf6b3 100644 --- a/src/wormhole/cli/cli.py +++ b/src/wormhole/cli/cli.py @@ -22,27 +22,13 @@ class Config(object): Union of config options that we pass down to (sub) commands. """ def __init__(self): - # common options + # This only holds attributes which are *not* set by CLI arguments. + # Everything else comes from Click decorators, so we can be sure + # we're exercising the defaults. self.timing = DebugTiming() - self.tor = None - self.listen = None - self.relay_url = u"" - self.transit_helper = u"" self.cwd = os.getcwd() - # send/receive commands - self.code = None - self.code_length = 2 - self.verify = False - self.hide_progress = False - self.dump_timing = False self.stdout = stdout self.stderr = stderr - self.zeromode = False - self.accept_file = None - self.output_file = None - # send only - self.text = None - self.what = None ALIASES = { diff --git a/src/wormhole/test/test_args.py b/src/wormhole/test/test_args.py index 8b87e24..6070372 100644 --- a/src/wormhole/test/test_args.py +++ b/src/wormhole/test/test_args.py @@ -14,7 +14,6 @@ class Send(unittest.TestCase): self.assertEqual(cfg.dump_timing, None) self.assertEqual(cfg.hide_progress, False) self.assertEqual(cfg.listen, True) - self.assertEqual(cfg.output_file, None) self.assertEqual(cfg.relay_url, RENDEZVOUS_RELAY) self.assertEqual(cfg.transit_helper, TRANSIT_RELAY) self.assertEqual(cfg.text, "hi") @@ -70,7 +69,6 @@ class Receive(unittest.TestCase): cfg = config("receive") #pprint(cfg.__dict__) self.assertEqual(cfg.accept_file, False) - self.assertEqual(cfg.what, None) self.assertEqual(cfg.code, None) self.assertEqual(cfg.code_length, 2) self.assertEqual(cfg.dump_timing, None) @@ -80,7 +78,6 @@ class Receive(unittest.TestCase): self.assertEqual(cfg.output_file, None) self.assertEqual(cfg.relay_url, RENDEZVOUS_RELAY) self.assertEqual(cfg.transit_helper, TRANSIT_RELAY) - self.assertEqual(cfg.text, None) self.assertEqual(cfg.tor, False) self.assertEqual(cfg.verify, False) self.assertEqual(cfg.zeromode, False)