move all tests into a root "tests" folder so they can share setup and config

This commit is contained in:
holger krekel
2023-10-20 22:56:24 +02:00
parent 848b25c790
commit c613ca24af
9 changed files with 10 additions and 4 deletions

View File

@@ -3,8 +3,8 @@ import os
import pytest import pytest
import chatmaild.dictproxy import chatmaild.dictproxy
from .dictproxy import get_user_data, lookup_passdb from chatmaild.dictproxy import get_user_data, lookup_passdb
from .database import Database, DBError from chatmaild.database import Database, DBError
@pytest.fixture() @pytest.fixture()

View File

@@ -1,4 +1,4 @@
from .filtermail import check_encrypted, check_DATA, SendRateLimiter from chatmaild.filtermail import check_encrypted, check_DATA, SendRateLimiter
from email.parser import BytesParser from email.parser import BytesParser
from email import policy from email import policy
import pytest import pytest

View File

@@ -6,10 +6,14 @@ import subprocess
import imaplib import imaplib
import smtplib import smtplib
import itertools import itertools
from pathlib import Path
from math import ceil from math import ceil
import pytest import pytest
conftestdir = Path(__file__).parent
def pytest_addoption(parser): def pytest_addoption(parser):
parser.addoption( parser.addoption(
"--slow", action="store_true", default=False, help="also run slow tests" "--slow", action="store_true", default=False, help="also run slow tests"
@@ -282,9 +286,11 @@ class Remote:
@pytest.fixture @pytest.fixture
def mailgen(request): def mailgen(request):
datadir = conftestdir.joinpath("mail-data")
class Mailgen: class Mailgen:
def get_encrypted(self, from_addr, to_addr): def get_encrypted(self, from_addr, to_addr):
data = request.fspath.dirpath("mailgen/encrypted.eml").read() data = datadir.joinpath("encrypted.eml").read_text()
return data.format(from_addr=from_addr, to_addr=to_addr) return data.format(from_addr=from_addr, to_addr=to_addr)
return Mailgen() return Mailgen()