From 8541a39c3328950dee8a2e79e673be970cb06e5f Mon Sep 17 00:00:00 2001 From: object-Object Date: Sun, 5 Nov 2023 13:04:14 -0500 Subject: [PATCH] Fix env patch not actually applying to the pytest export --- .../test_files[vlatestindex.html].raw | 180 +++++++++--------- test/_cli/test_main.py | 14 +- test/conftest.py | 8 +- 3 files changed, 104 insertions(+), 98 deletions(-) diff --git a/test/_cli/__snapshots__/test_main/test_files[vlatestindex.html].raw b/test/_cli/__snapshots__/test_main/test_files[vlatestindex.html].raw index 373bb8d8..cb91b16c 100644 --- a/test/_cli/__snapshots__/test_main/test_files[vlatestindex.html].raw +++ b/test/_cli/__snapshots__/test_main/test_files[vlatestindex.html].raw @@ -604,7 +604,7 @@
Spotlight inventory slot Spotlight inventory slot Spotlight inventory slot Crafting table
@@ -745,7 +745,7 @@
Crafting table
@@ -810,7 +810,7 @@
Crafting table
@@ -875,7 +875,7 @@
Crafting table
@@ -940,7 +940,7 @@
Crafting table
@@ -1005,7 +1005,7 @@
Crafting table
@@ -1070,7 +1070,7 @@
Crafting table
@@ -1135,7 +1135,7 @@
Crafting table
@@ -1200,7 +1200,7 @@
Crafting table
@@ -1265,7 +1265,7 @@
Crafting table
@@ -1355,7 +1355,7 @@
Crafting table
@@ -1447,7 +1447,7 @@
Crafting table
@@ -1512,7 +1512,7 @@
Crafting table
@@ -1666,7 +1666,7 @@
Crafting table
@@ -1876,7 +1876,7 @@
Crafting table
@@ -2023,7 +2023,7 @@
Crafting table
@@ -2061,7 +2061,7 @@
Crafting table
@@ -2126,7 +2126,7 @@
Crafting table
@@ -2252,7 +2252,7 @@
Crafting table
@@ -2343,7 +2343,7 @@
Crafting table
@@ -2436,7 +2436,7 @@
Crafting table
@@ -2540,7 +2540,7 @@
Crafting table
@@ -2647,7 +2647,7 @@
Spotlight inventory slot Crafting table
@@ -2750,7 +2750,7 @@
Crafting table
@@ -2814,7 +2814,7 @@
Crafting table
@@ -2878,7 +2878,7 @@
Crafting table
@@ -2942,7 +2942,7 @@
Crafting table
@@ -3006,7 +3006,7 @@
Crafting table
@@ -3070,7 +3070,7 @@
Crafting table
@@ -3134,7 +3134,7 @@
Crafting table
@@ -3198,7 +3198,7 @@
Crafting table
@@ -3262,7 +3262,7 @@
Crafting table
@@ -3326,7 +3326,7 @@
Crafting table
@@ -3390,7 +3390,7 @@
Crafting table
@@ -3454,7 +3454,7 @@
Crafting table
@@ -3518,7 +3518,7 @@
Crafting table
@@ -3582,7 +3582,7 @@
Crafting table
@@ -3656,7 +3656,7 @@
Crafting table
@@ -3720,7 +3720,7 @@
Crafting table
@@ -3784,7 +3784,7 @@
Crafting table
@@ -3848,7 +3848,7 @@
Crafting table
@@ -3912,7 +3912,7 @@
Crafting table
@@ -3976,7 +3976,7 @@
Crafting table
@@ -4040,7 +4040,7 @@
Crafting table
@@ -4104,7 +4104,7 @@
Crafting table
@@ -4168,7 +4168,7 @@
Crafting table
@@ -4232,7 +4232,7 @@
Crafting table
@@ -4296,7 +4296,7 @@
Crafting table
@@ -4360,7 +4360,7 @@
Crafting table
@@ -4424,7 +4424,7 @@
Crafting table
@@ -4488,7 +4488,7 @@
Crafting table
@@ -4559,7 +4559,7 @@
Crafting table
@@ -4623,7 +4623,7 @@
Crafting table
@@ -4698,7 +4698,7 @@
Crafting table
@@ -4798,7 +4798,7 @@
Crafting table
@@ -4922,7 +4922,7 @@
Crafting table
@@ -5008,7 +5008,7 @@
Crafting table
@@ -5209,7 +5209,7 @@
Crafting table
@@ -5320,7 +5320,7 @@
Crafting table
@@ -5581,7 +5581,7 @@
Crafting table
@@ -5782,7 +5782,7 @@
Crafting table
@@ -5983,7 +5983,7 @@
Crafting table
@@ -6184,7 +6184,7 @@
Crafting table
@@ -6234,7 +6234,7 @@
Crafting table
@@ -6338,7 +6338,7 @@
Crafting table
@@ -6454,7 +6454,7 @@
Crafting table
@@ -6556,7 +6556,7 @@
Crafting table
@@ -6594,7 +6594,7 @@
Crafting table
@@ -6696,7 +6696,7 @@
Crafting table
@@ -6812,7 +6812,7 @@
Crafting table
@@ -6850,7 +6850,7 @@
Crafting table
@@ -6888,7 +6888,7 @@
Crafting table
@@ -7014,7 +7014,7 @@
Crafting table
@@ -7126,7 +7126,7 @@
Crafting table
@@ -7182,7 +7182,7 @@
Crafting table
@@ -7212,7 +7212,7 @@
Crafting table
@@ -7380,7 +7380,7 @@
Crafting table
@@ -7525,7 +7525,7 @@
Crafting table
@@ -7663,7 +7663,7 @@
Crafting table
@@ -8030,7 +8030,7 @@
Crafting table
@@ -8424,7 +8424,7 @@
Spotlight inventory slot
Crafting table
@@ -8542,7 +8542,7 @@
Crafting table
@@ -8604,7 +8604,7 @@
Crafting table
@@ -8690,7 +8690,7 @@
Crafting table
@@ -8801,7 +8801,7 @@
Crafting table
diff --git a/test/_cli/test_main.py b/test/_cli/test_main.py index 423cd312..5fb3cc59 100644 --- a/test/_cli/test_main.py +++ b/test/_cli/test_main.py @@ -28,16 +28,16 @@ def list_directory(root: str | Path, glob: str = "**/*") -> list[str]: return sorted(path.relative_to(root).as_posix() for path in root.glob(glob)) -@pytest.fixture(autouse=True) -def patch_env(monkeypatch: MonkeyPatch): - monkeypatch.setenv("GITHUB_REPOSITORY", "GITHUB_REPOSITORY") - monkeypatch.setenv("GITHUB_SHA", "GITHUB_SHA") - monkeypatch.setenv("GITHUB_PAGES_URL", "GITHUB_PAGES_URL") - monkeypatch.setenv("DEBUG_GITHUBUSERCONTENT", "DEBUG_GITHUBUSERCONTENT") +@pytest.fixture(autouse=True, scope="session") +def patch_env(monkeysession: MonkeyPatch): + monkeysession.setenv("GITHUB_REPOSITORY", "GITHUB_REPOSITORY") + monkeysession.setenv("GITHUB_SHA", "GITHUB_SHA") + monkeysession.setenv("GITHUB_PAGES_URL", "GITHUB_PAGES_URL") + monkeysession.setenv("DEBUG_GITHUBUSERCONTENT", "DEBUG_GITHUBUSERCONTENT") @pytest.fixture(autouse=True, scope="session") -def export_hexdoc_data(): +def export_hexdoc_data(patch_env: None): export(props_file=Path("properties.toml")) export(props_file=HEXCASTING_PROPS_FILE) diff --git a/test/conftest.py b/test/conftest.py index 9f6a4965..f862a356 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -2,7 +2,7 @@ from typing import Any import pytest -from pytest import Parser +from pytest import MonkeyPatch, Parser from syrupy.assertion import SnapshotAssertion from syrupy.extensions.single_file import SingleFileSnapshotExtension, WriteMode from syrupy.types import SerializableData, SerializedData @@ -53,3 +53,9 @@ def path_snapshot(snapshot: SnapshotAssertion): @pytest.fixture def pm(): return PluginManager() + + +@pytest.fixture(scope="session") +def monkeysession(): + with MonkeyPatch.context() as mp: + yield mp