Skip to content

Commit 1b7d463

Browse files
Merge pull request #110 from discord-modmail/hotfix-patch-embed
hotfix: patch embeds throughout the entire test suite
2 parents 9b5dac9 + d76de1c commit 1b7d463

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

tests/conftest.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
11
import pytest
2-
3-
4-
def pytest_report_header(config) -> str:
5-
"""Pytest headers."""
6-
return "package: modmail"

tests/modmail/conftest.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import pytest
2+
3+
4+
def pytest_report_header(config) -> str:
5+
"""Pytest headers."""
6+
return "package: modmail"
7+
8+
9+
@pytest.fixture(autouse=True, scope="package")
10+
def patch_embeds():
11+
"""Run the patch embed method. This is normally run by modmail.__main__, which is not run for testing."""
12+
import modmail.utils.embeds
13+
14+
modmail.utils.embeds.patch_embed()

tests/modmail/utils/test_embeds.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import unittest.mock
2+
13
import discord
24
import pytest
35

@@ -10,9 +12,10 @@ def test_patch_embed() -> None:
1012
from modmail.utils.embeds import __init__ as init
1113
from modmail.utils.embeds import original_init
1214

13-
assert discord.Embed.__init__ == original_init
14-
patch_embed()
15-
assert discord.Embed.__init__ == init
15+
with unittest.mock.patch.object(discord.Embed, "__init__", original_init):
16+
assert discord.Embed.__init__ == original_init
17+
patch_embed()
18+
assert discord.Embed.__init__ == init
1619

1720

1821
@pytest.mark.dependency(depends_on="patch_embed")

0 commit comments

Comments
 (0)