From b27c62e7d11d4c221666e7e0241a8ea51902be88 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Sat, 3 Oct 2020 17:45:47 +0000 Subject: [PATCH] Make selftest dialogue mutable In order to support future selectivity of test sets, replace the immutable tuple of all tests with a dict keyed by test object. Iterate over a copy of it so that the original is not altered when tests are eventually removed during runtime. For Python 3.5 and earlier, use OrderedDict so that test order is explicitly preserved. --- mudpy/tests/selftest.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/mudpy/tests/selftest.py b/mudpy/tests/selftest.py index b1eb7cf..d5b8ac4 100644 --- a/mudpy/tests/selftest.py +++ b/mudpy/tests/selftest.py @@ -11,6 +11,13 @@ import sys import telnetlib import time +# TODO(fungi) Clean this up once Python 3.5 is no longer supported +if sys.version < "3.6": + import collections + odict = collections.OrderedDict +else: + odict = dict + pidfile = "var/mudpy.pid" test_account0_setup = ( @@ -378,7 +385,7 @@ final_cleanup = ( (2, r"Disconnecting\.\.\.", ""), ) -dialogue = ( +dialogue = odict(( (test_account0_setup, "first account setup"), (test_account1_setup, "second account setup"), (test_actor_appears, "actor spontaneous appearance"), @@ -423,7 +430,7 @@ dialogue = ( (test_invalid_loglevel, "invalid loglevel"), (test_log_no_errors, "no errors logged"), (final_cleanup, "delete remaining accounts"), -) +)) def start_service(config): @@ -534,7 +541,8 @@ def main(): for luser in lusers: luser.open("::1", 4000) luser.set_option_negotiation_callback(option_callback) - for test, description in dialogue: + selected_dialogue = odict(dialogue) + for test, description in selected_dialogue.items(): tlog("\nTesting %s..." % description) test_start = time.time() for conversant, question, answer in test: -- 2.11.0