From 56445d776553aac36a48ceadff3c69283646526e Mon Sep 17 00:00:00 2001 From: Hartmut Goebel Date: Mon, 3 May 2021 14:10:53 +0200 Subject: [PATCH] tests: python: Change names of dummy home directories. --- .gitignore | 2 ++ test/python_tests/setup_test.py | 27 ++++++++++++++------------- test/python_tests/test_handshake.py | 11 ++++++----- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 802485ef7..5b3635a8d 100644 --- a/.gitignore +++ b/.gitignore @@ -57,6 +57,8 @@ __pycache__ *.pyc test/gtest_parallel.py test/python_tests/test? +test/python_tests/dummyhome? +test/python_tests/common test/pEp_test_home test/TestDriver test/local diff --git a/test/python_tests/setup_test.py b/test/python_tests/setup_test.py index be9d94385..8cff9812e 100755 --- a/test/python_tests/setup_test.py +++ b/test/python_tests/setup_test.py @@ -34,7 +34,7 @@ def link_if_exists(dirname, arthome): os.symlink(orig, dirname, True) -def create_own_identities(mydir, arthome, username): +def create_own_identities(mydir, arthome, addr, username): "create own identities as part of the test setup" os.environ["HOME"] = os.path.join(mydir, arthome) @@ -42,7 +42,7 @@ def create_own_identities(mydir, arthome, username): import pEp me = pEp.Identity() - me.address = arthome + "@peptest.ch" + me.address = addr + "@peptest.ch" me.username = username pEp.myself(me) @@ -57,7 +57,7 @@ def link_file(filename): os.symlink(src, filename, False) -def create_home(mydir, arthome, username): +def create_home(mydir, arthome, addr, username): "create an artificial home directory for testing" os.chdir(mydir) @@ -72,7 +72,8 @@ def create_home(mydir, arthome, username): link_if_exists(".local", arthome) link_if_exists("Library", arthome) # this may exist on macOS - p = Process(target=create_own_identities, args=(mydir, arthome, username)) + p = Process(target=create_own_identities, + args=(mydir, arthome, addr, username)) p.start() p.join() @@ -83,20 +84,20 @@ def create_homes(): "create two artificial home directories for the two parties" try: - os.stat("test1") + os.stat("dummyhome1") except FileNotFoundError: - create_home(mydir, "test1", "Alice One") - create_home(mydir, "test2", "Bob Two") + create_home(mydir, "dummyhome1", "test1", "Alice One") + create_home(mydir, "dummyhome2", "test2", "Bob Two") os.chdir(mydir); os.makedirs("common", exist_ok=True) # common inbox for Sync tests else: while True: try: - os.stat("test2/.ready") - except: - sleep(1) - else: + os.stat("dummyhome1/.ready") + os.stat("dummyhome2/.ready") break + except: + sleep(0.01) def remove_homes(): @@ -104,8 +105,8 @@ def remove_homes(): contents""" os.chdir(mydir) - shutil.rmtree("test1", ignore_errors=True) - shutil.rmtree("test2", ignore_errors=True) + shutil.rmtree("dummyhome1", ignore_errors=True) + shutil.rmtree("dummyhome2", ignore_errors=True) shutil.rmtree("common", ignore_errors=True) shutil.rmtree("__pycache__", ignore_errors=True) diff --git a/test/python_tests/test_handshake.py b/test/python_tests/test_handshake.py index 4e52fa5c4..fe851e7eb 100644 --- a/test/python_tests/test_handshake.py +++ b/test/python_tests/test_handshake.py @@ -43,7 +43,7 @@ def test_handshake(): def process1(): print("process1 starting") - setup_gnupg("test1") ; import pEp + setup_gnupg("dummyhome1") ; import pEp me = Me(ALICE) you = You(BOB) @@ -53,7 +53,7 @@ def test_handshake(): msg.longmsg = "Message Text\n" enc = msg.encrypt() - send_message("test2", str(enc)) + send_message("dummyhome2", str(enc)) txt = wait_for_message() enc = pEp.Message(txt) @@ -67,12 +67,13 @@ def test_handshake(): msg.longmsg = "Message Text complete\n" enc = msg.encrypt() - send_message("test2", str(enc)) + send_message("dummyhome2", str(enc)) print("process1 finishing") def process2(): print("process2 starting") - setup_gnupg("test2") ; import pEp + setup_gnupg("dummyhome2") ; import pEp + me = Me(BOB) you = You(ALICE) @@ -87,7 +88,7 @@ def test_handshake(): out.longmsg = "Text Back\n" enc = out.encrypt() - send_message("test1", str(enc)) + send_message("dummyhome1", str(enc)) txt = wait_for_message() msg = pEp.Message(txt)