From b5d8256def0233771e78c81f42b1e879aef3702e Mon Sep 17 00:00:00 2001 From: Vaclav Petras Date: Fri, 3 May 2024 14:24:03 -0400 Subject: [PATCH] Add mock for tests --- python/grass/script/tests/conftest.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 python/grass/script/tests/conftest.py diff --git a/python/grass/script/tests/conftest.py b/python/grass/script/tests/conftest.py new file mode 100644 index 00000000000..ce666fbdeef --- /dev/null +++ b/python/grass/script/tests/conftest.py @@ -0,0 +1,20 @@ +"""Fixtures for grass.script""" + +import pytest + + +@pytest.fixture +def mock_no_session(monkeypatch): + """Set the environment variables as if there would be no background session. + + Use with usefixtures (not as a paramter) to avoid warnings about an unused + parameter:: + + @pytest.mark.usefixtures("mock_no_session") + def test_session_handling(): + pass + + There may or may not be a session in the background (we don't check either way). + """ + monkeypatch.delenv("GISRC", raising=False) + monkeypatch.delenv("GISBASE", raising=False)