diff --git a/online-tests/conftest.py b/online-tests/conftest.py index e1167663..4191ff08 100644 --- a/online-tests/conftest.py +++ b/online-tests/conftest.py @@ -1,7 +1,6 @@ import os import io import random -import contextlib import subprocess import imaplib import smtplib @@ -156,24 +155,6 @@ class ChatmailTestProcess: pass -@pytest.fixture -def switch_maildomain(): - """return a function that allows to switch an account factory temporarily - to another maildomain. - """ - - # nb. a bit hacky - # would probably be better if deltachat's test machinery grows native support - @contextlib.contextmanager - def switch(acfactory, maildomain2): - old_domain = acfactory.testprocess.maildomain - acfactory.testprocess.maildomain = maildomain2 - yield - acfactory.testprocess.maildomain = old_domain - - return switch - - @pytest.fixture def cmfactory(request, gencreds, tmpdir, data, maildomain): # cloned from deltachat.testplugin.amfactory @@ -182,6 +163,14 @@ def cmfactory(request, gencreds, tmpdir, data, maildomain): testproc = ChatmailTestProcess(request.config, maildomain, gencreds) am = ACFactory(request=request, tmpdir=tmpdir, testprocess=testproc, data=data) + + # nb. a bit hacky + # would probably be better if deltachat's test machinery grows native support + def switch_maildomain(maildomain2): + am.testprocess.maildomain = maildomain2 + + am.switch_maildomain = switch_maildomain + yield am if hasattr(request.node, "rep_call") and request.node.rep_call.failed: if testproc.pytestconfig.getoption("--extra-info"): diff --git a/online-tests/test_0_basic.py b/online-tests/test_0_basic.py index f4d090b9..8ad202b3 100644 --- a/online-tests/test_0_basic.py +++ b/online-tests/test_0_basic.py @@ -4,10 +4,11 @@ def test_remotelog(remotelog, imap_or_smtp): assert imap_or_smtp.logunit in next(lineproducer) -def test_use_two_chatmailservers(cmfactory, maildomain2, switch_maildomain): - (ac1,) = cmfactory.get_online_accounts(1) - with switch_maildomain(cmfactory, maildomain2): - (ac2,) = cmfactory.get_online_accounts(1) +def test_use_two_chatmailservers(cmfactory, maildomain2): + ac1 = cmfactory.new_online_configuring_account(cache=False) + cmfactory.switch_maildomain(maildomain2) + ac2 = cmfactory.new_online_configuring_account(cache=False) + cmfactory.bring_accounts_online() cmfactory.get_accepted_chat(ac1, ac2) domain1 = ac1.get_config("addr").split("@")[1] domain2 = ac2.get_config("addr").split("@")[1]