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) 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)