summaryrefslogtreecommitdiffstats
path: root/contrib/python/wcwidth/py3/tests/conftest.py
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/python/wcwidth/py3/tests/conftest.py')
-rw-r--r--contrib/python/wcwidth/py3/tests/conftest.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/contrib/python/wcwidth/py3/tests/conftest.py b/contrib/python/wcwidth/py3/tests/conftest.py
index ecbbdc876e0..dbaaed8faa5 100644
--- a/contrib/python/wcwidth/py3/tests/conftest.py
+++ b/contrib/python/wcwidth/py3/tests/conftest.py
@@ -1,8 +1,29 @@
"""Pytest configuration and fixtures."""
+# std imports
+import os
+
# 3rd party
import pytest
+# local
+from wcwidth._constants import resolve_terminal
+
+
[email protected](autouse=True)
+def _clear_resolve_terminal_cache():
+ """Clear resolve_terminal cache and unset TERM/TERM_PROGRAM before each test."""
+ saved_term = os.environ.pop('TERM', None)
+ saved_tprog = os.environ.pop('TERM_PROGRAM', None)
+ resolve_terminal.cache_clear()
+ yield
+ resolve_terminal.cache_clear()
+ if saved_term is not None:
+ os.environ['TERM'] = saved_term
+ if saved_tprog is not None:
+ os.environ['TERM_PROGRAM'] = saved_tprog
+
+
try:
# 3rd party
from pytest_codspeed import BenchmarkFixture # noqa: F401 pylint:disable=unused-import