From 926de760109b1a67940ff07657e2d50794262679 Mon Sep 17 00:00:00 2001 From: missytake Date: Sat, 17 Feb 2024 10:17:20 +0100 Subject: [PATCH] tests: make maildata work with python3.9 --- chatmaild/src/chatmaild/tests/plugin.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/chatmaild/src/chatmaild/tests/plugin.py b/chatmaild/src/chatmaild/tests/plugin.py index e9383fbc..98dc83bf 100644 --- a/chatmaild/src/chatmaild/tests/plugin.py +++ b/chatmaild/src/chatmaild/tests/plugin.py @@ -1,4 +1,6 @@ import random +from pathlib import Path +import os import importlib.resources import itertools from email.parser import BytesParser @@ -57,7 +59,12 @@ def db(tmpdir): @pytest.fixture def maildata(request): - datadir = importlib.resources.files(__package__).joinpath("mail-data") + try: + datadir = importlib.resources.files(__package__).joinpath("mail-data") + except TypeError: + # in python3.9 or lower, the above doesn't work, so we get datadir this way: + datadir = Path(os.getcwd()).joinpath("chatmaild/src/chatmaild/tests/mail-data") + assert datadir.exists(), datadir def maildata(name, from_addr, to_addr):