commit 4938ad08bf041d82d3465d03a6c47f198c04085a Author: Arturo Filastò art@fuffa.org Date: Thu Feb 20 18:39:07 2014 +0000
Fix bug that leads to not showing the help if an option is not present. --- ooni/deck.py | 15 +++++++++------ ooni/nettest.py | 5 ++++- 2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/ooni/deck.py b/ooni/deck.py index 260f8b4..79f8f48 100644 --- a/ooni/deck.py +++ b/ooni/deck.py @@ -122,16 +122,19 @@ class Deck(InputFile):
def insert(self, net_test_loader): """ Add a NetTestLoader to this test deck """ + def has_test_helper(missing_option): + for rth in net_test_loader.requiredTestHelpers: + if missing_option == rth['option']: + return True + return False try: net_test_loader.checkOptions() - except e.MissingRequiredOption, option_name: + except e.MissingRequiredOption, missing_options: if not self.bouncer: raise - for rth in net_test_loader.requiredTestHelpers: - if option_name.message == rth['option']: - break - else: - raise + for missing_option in missing_options.message: + if not has_test_helper(missing_option): + raise self.netTestLoaders.append(net_test_loader)
@defer.inlineCallbacks diff --git a/ooni/nettest.py b/ooni/nettest.py index 1780953..ec80bf7 100644 --- a/ooni/nettest.py +++ b/ooni/nettest.py @@ -758,11 +758,14 @@ class NetTestCase(object): raise e.InvalidOption
def _checkRequiredOptions(self): + missing_options = [] for required_option in self.requiredOptions: log.debug("Checking if %s is present" % required_option) if required_option not in self.localOptions or \ self.localOptions[required_option] == None: - raise e.MissingRequiredOption(required_option) + missing_options.append(required_option) + if missing_options: + raise e.MissingRequiredOption(missing_options)
def __repr__(self): return "<%s inputs=%s>" % (self.__class__, self.inputs)
tor-commits@lists.torproject.org