From b961df90a72f506f4a58c236fd3712cebb1523ff Mon Sep 17 00:00:00 2001 From: Trenton H <797416+stumpylog@users.noreply.github.com> Date: Mon, 7 Aug 2023 12:08:35 -0700 Subject: [PATCH] Reduces the 2 mail tests flakiness --- Pipfile | 2 ++ Pipfile.lock | 12 +++++++++++- src/paperless_mail/tests/test_mail.py | 15 +++++++-------- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Pipfile b/Pipfile index 4bd0ed325..623ba5e1f 100644 --- a/Pipfile +++ b/Pipfile @@ -81,12 +81,14 @@ pytest-httpx = "*" pytest-env = "*" pytest-sugar = "*" pytest-xdist = "*" +pytest-rerunfailures = "*" "pdfminer.six" = "*" imagehash = "*" daphne = "*" # Documentation mkdocs-material = "*" + [typing-dev] mypy = "*" types-Pillow = "*" diff --git a/Pipfile.lock b/Pipfile.lock index 82337c08d..30ec9c90b 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "3913b5fd4b48095586e377129b3ba37f2d4610f44ae0edab736f81e103a8a837" + "sha256": "6ec43d0989237b0ed7da3e3306be49a1c637d2ad44222cf097b25c64c3e8d76d" }, "pipfile-spec": 6, "requires": {}, @@ -2921,6 +2921,7 @@ "sha256:b4bf8c45bd59934ed84001ad51e11b4ee40d40a1229d2c79f9c592b0a3f6bd8a" ], "index": "pypi", + "markers": "python_version >= '3.7'", "version": "==7.4.0" }, "pytest-cov": { @@ -2955,6 +2956,15 @@ "index": "pypi", "version": "==0.22.0" }, + "pytest-rerunfailures": { + "hashes": [ + "sha256:784f462fa87fe9bdf781d0027d856b47a4bfe6c12af108f6bd887057a917b48e", + "sha256:9a1afd04e21b8177faf08a9bbbf44de7a0fe3fc29f8ddbe83b9684bd5f8f92a9" + ], + "index": "pypi", + "markers": "python_version >= '3.7'", + "version": "==12.0" + }, "pytest-sugar": { "hashes": [ "sha256:8cb5a4e5f8bbcd834622b0235db9e50432f4cbd71fef55b467fe44e43701e062", diff --git a/src/paperless_mail/tests/test_mail.py b/src/paperless_mail/tests/test_mail.py index 82b874fd8..d7f543def 100644 --- a/src/paperless_mail/tests/test_mail.py +++ b/src/paperless_mail/tests/test_mail.py @@ -9,6 +9,7 @@ from typing import Optional from typing import Union from unittest import mock +import pytest from django.core.management import call_command from django.db import DatabaseError from django.test import TestCase @@ -400,8 +401,7 @@ class TestMail( attachments=2, ) - account = MailAccount() - account.save() + account = MailAccount.objects.create() rule = MailRule( assign_title_from=MailRule.TitleSource.FROM_FILENAME, account=account, @@ -445,8 +445,7 @@ class TestMail( ], ) - account = MailAccount() - account.save() + account = MailAccount.objects.create() rule = MailRule( assign_title_from=MailRule.TitleSource.FROM_FILENAME, account=account, @@ -475,8 +474,7 @@ class TestMail( ], ) - account = MailAccount() - account.save() + account = MailAccount.objects.create() rule = MailRule( assign_title_from=MailRule.TitleSource.FROM_FILENAME, account=account, @@ -504,8 +502,7 @@ class TestMail( ], ) - account = MailAccount() - account.save() + account = MailAccount.objects.create() rule = MailRule( assign_title_from=MailRule.TitleSource.FROM_FILENAME, account=account, @@ -696,6 +693,7 @@ class TestMail( self.assertEqual(len(self.bogus_mailbox.fetch("UNFLAGGED", False)), 1) self.assertEqual(len(self.bogus_mailbox.messages), 3) + @pytest.mark.flaky(reruns=4) def test_handle_mail_account_move(self): account = MailAccount.objects.create( name="test", @@ -854,6 +852,7 @@ class TestMail( ): self.mail_account_handler.handle_mail_account(account) + @pytest.mark.flaky(reruns=4) def test_error_skip_account(self): _ = MailAccount.objects.create( name="test",