From cc229372e428bcf1b2ef81005f9029fdbfbd9c8a Mon Sep 17 00:00:00 2001 From: holger krekel Date: Tue, 11 Aug 2026 20:11:38 +0200 Subject: [PATCH] test: provide complete test isolation by not re-using account addresses As we are using a dedicated CI relay instance, we don't need to be careful with creating test addresses. But re-using test addresses in a test running in a single worker can leak events/messages which compromises test isolation. Instead of encountering random flaky tests because let's just not cache addresses to maximize test isolation. --- python/src/deltachat/testplugin.py | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/python/src/deltachat/testplugin.py b/python/src/deltachat/testplugin.py index 3306d7007..18d3e00d7 100644 --- a/python/src/deltachat/testplugin.py +++ b/python/src/deltachat/testplugin.py @@ -157,27 +157,18 @@ class TestProcess: self._configlist: List[Dict[str, str]] = [] def get_liveconfig_producer(self): - """provide live account configs, cached on a per-test-process scope - so that test functions can reuse already known live configs. - """ + """provide fresh live account configs for each requested account.""" chatmail_opt = self.pytestconfig.getoption("--chatmail") if chatmail_opt: - # Use a chatmail instance. domain = chatmail_opt - MAX_LIVE_CREATED_ACCOUNTS = 10 - for index in range(MAX_LIVE_CREATED_ACCOUNTS): - try: - yield self._configlist[index] - except IndexError: - part = "".join(random.choices("2345789acdefghjkmnpqrstuvwxyz", k=6)) - username = f"ci-{part}" - password = f"{username}${username}" - addr = f"{username}@{domain}" - config = {"addr": addr, "mail_pw": password} - print("newtmpuser {}: addr={}".format(index, config["addr"])) - self._configlist.append(config) - yield config - pytest.fail(f"more than {MAX_LIVE_CREATED_ACCOUNTS} live accounts requested.") + while True: + part = "".join(random.choices("2345789acdefghjkmnpqrstuvwxyz", k=6)) + username = f"ci-{part}" + password = f"{username}${username}" + addr = f"{username}@{domain}" + config = {"addr": addr, "mail_pw": password} + print("newtmpuser: addr={}".format(config["addr"])) + yield config else: pytest.skip( "specify CHATMAIL_DOMAIN or --chatmail to provide live accounts",