From c778d32a401e63c8d1b8ddd8084ae442263b5444 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sat, 29 Feb 2020 10:35:26 -0600 Subject: [PATCH 1/2] pytest: Clear env variables --- tests/conftest.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 05fee0c83..a3312eed4 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import logging +import os import pytest @@ -11,8 +12,37 @@ logger = logging.getLogger(__name__) +@pytest.fixture(autouse=True) +def clear_env(monkeypatch): + """Clear out any unnecessary environment variables that could interrupt tests. + + tmux show-environment tests were being interrupted due to a lot of crazy env vars. + """ + for k, v in os.environ.items(): + if not any( + needle in k.lower() + for needle in [ + 'window', + 'tmux', + 'pane', + 'session', + 'pytest', + 'path', + 'pwd', + 'shell', + 'home', + 'xdg', + 'disable_auto_title', + 'lang', + 'term', + ] + ): + monkeypatch.delenv(k) + + @pytest.fixture(scope='function') -def server(request): +def server(request, monkeypatch): + t = Server() t.socket_name = 'tmuxp_test%s' % next(namer) From 2be29c88098d4dde8bf8ee16f502f04b09ebf5e3 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sat, 29 Feb 2020 10:36:55 -0600 Subject: [PATCH 2/2] Update CHANGES --- CHANGES | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES b/CHANGES index 345ef36e2..5d2e1a344 100644 --- a/CHANGES +++ b/CHANGES @@ -9,6 +9,8 @@ current - :issue:`303` Add ``common.get_libtmux_version`` which gives the tmux version as a loose constraint. Fix linking to terms inside docs, and duplicate description of module which sphinx warned about in api.rst. +- :issue:`266` Fix issue on local tests where env variables would cause + show-environment to pause tests indefinitely. - *Insert changes/features/fixes for next release here* libtmux 0.8.4 (2020-10-25)