From f589ef42abc35aee93afadc398cbf0ba2c543fef Mon Sep 17 00:00:00 2001 From: holger krekel Date: Sun, 1 Mar 2026 23:51:44 +0100 Subject: [PATCH] test: load test data through the `data` fixture Relative paths only worked when running from `deltachat-rpc-client`. --- deltachat-rpc-client/tests/test_chatlist_events.py | 4 ++-- deltachat-rpc-client/tests/test_multitransport.py | 4 ++-- deltachat-rpc-client/tests/test_something.py | 4 ++-- deltachat-rpc-client/tests/test_webxdc.py | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/deltachat-rpc-client/tests/test_chatlist_events.py b/deltachat-rpc-client/tests/test_chatlist_events.py index a6152049d..ed2fc3c74 100644 --- a/deltachat-rpc-client/tests/test_chatlist_events.py +++ b/deltachat-rpc-client/tests/test_chatlist_events.py @@ -110,7 +110,7 @@ def test_delivery_status_failed(acfactory: ACFactory) -> None: assert failing_message.get_snapshot().state == const.MessageState.OUT_FAILED -def test_download_on_demand(acfactory: ACFactory) -> None: +def test_download_on_demand(acfactory: ACFactory, data) -> None: """ Test if download on demand emits chatlist update events. This is only needed for last message in chat, but finding that out is too expensive, so it's always emitted @@ -128,7 +128,7 @@ def test_download_on_demand(acfactory: ACFactory) -> None: msg.get_snapshot().chat.accept() bob.get_chat_by_id(chat_id).send_message( "Hello World, this message is bigger than 5 bytes", - file="../test-data/image/screenshot.jpg", + file=data.get_path("image/screenshot.jpg"), ) message = alice.wait_for_incoming_msg() diff --git a/deltachat-rpc-client/tests/test_multitransport.py b/deltachat-rpc-client/tests/test_multitransport.py index 6b6bf010d..b0ab29288 100644 --- a/deltachat-rpc-client/tests/test_multitransport.py +++ b/deltachat-rpc-client/tests/test_multitransport.py @@ -76,7 +76,7 @@ def test_change_address(acfactory) -> None: assert sender_addr2 == new_alice_addr -def test_download_on_demand(acfactory) -> None: +def test_download_on_demand(acfactory, data) -> None: alice, bob = acfactory.get_online_accounts(2) alice.set_config("download_limit", "1") @@ -87,7 +87,7 @@ def test_download_on_demand(acfactory) -> None: alice.create_chat(bob) chat_bob_alice = bob.create_chat(alice) - chat_bob_alice.send_message(file="../test-data/image/screenshot.jpg") + chat_bob_alice.send_message(file=data.get_path("image/screenshot.jpg")) msg = alice.wait_for_incoming_msg() snapshot = msg.get_snapshot() assert snapshot.download_state == DownloadState.AVAILABLE diff --git a/deltachat-rpc-client/tests/test_something.py b/deltachat-rpc-client/tests/test_something.py index 7bebeff61..b55d7973d 100644 --- a/deltachat-rpc-client/tests/test_something.py +++ b/deltachat-rpc-client/tests/test_something.py @@ -1412,7 +1412,7 @@ def test_synchronize_member_list_on_group_rejoin(acfactory, log): assert msg.get_snapshot().chat.num_contacts() == 2 -def test_large_message(acfactory) -> None: +def test_large_message(acfactory, data) -> None: """ Test sending large message without download limit set, so it is sent with pre-message but downloaded without user interaction. @@ -1422,7 +1422,7 @@ def test_large_message(acfactory) -> None: alice_chat_bob = alice.create_chat(bob) alice_chat_bob.send_message( "Hello World, this message is bigger than 5 bytes", - file="../test-data/image/screenshot.jpg", + file=data.get_path("image/screenshot.jpg"), ) msg = bob.wait_for_incoming_msg() diff --git a/deltachat-rpc-client/tests/test_webxdc.py b/deltachat-rpc-client/tests/test_webxdc.py index 6e2dec46a..82d2b5652 100644 --- a/deltachat-rpc-client/tests/test_webxdc.py +++ b/deltachat-rpc-client/tests/test_webxdc.py @@ -1,9 +1,9 @@ -def test_webxdc(acfactory) -> None: +def test_webxdc(acfactory, data) -> None: alice, bob = acfactory.get_online_accounts(2) alice_contact_bob = alice.create_contact(bob, "Bob") alice_chat_bob = alice_contact_bob.create_chat() - alice_chat_bob.send_message(text="Let's play chess!", file="../test-data/webxdc/chess.xdc") + alice_chat_bob.send_message(text="Let's play chess!", file=data.get_path("webxdc/chess.xdc")) event = bob.wait_for_incoming_msg_event() bob_chat_alice = bob.get_chat_by_id(event.chat_id) @@ -43,12 +43,12 @@ def test_webxdc(acfactory) -> None: ] -def test_webxdc_insert_lots_of_updates(acfactory) -> None: +def test_webxdc_insert_lots_of_updates(acfactory, data) -> None: alice, bob = acfactory.get_online_accounts(2) alice_contact_bob = alice.create_contact(bob, "Bob") alice_chat_bob = alice_contact_bob.create_chat() - message = alice_chat_bob.send_message(text="Let's play chess!", file="../test-data/webxdc/chess.xdc") + message = alice_chat_bob.send_message(text="Let's play chess!", file=data.get_path("webxdc/chess.xdc")) for i in range(2000): message.send_webxdc_status_update({"payload": str(i)}, "description")