summaryrefslogtreecommitdiff
path: root/unittests/baseplatformtests.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2024-11-18 13:36:58 -0800
committerDylan Baker <dylan@pnwbakers.com>2025-01-27 09:36:33 -0800
commit1d2627ddbfe2972ae5676f60a30f4d4fde7f4e04 (patch)
treecb556a04fc73c99aea4b47d6ff185af88db41ef6 /unittests/baseplatformtests.py
parente2d32eb0f73efd75a3d22d007fed45df637e321e (diff)
downloadmeson-1d2627ddbfe2972ae5676f60a30f4d4fde7f4e04.tar.gz
tests: mock the environment in setUpClass
When used as a class decorator VSCode can no longer see that BasePlatformTest is a TestCase. I hate having to adapt the code to the tools, but it's really annoying to not have completion and syntax highlighting.
Diffstat (limited to 'unittests/baseplatformtests.py')
-rw-r--r--unittests/baseplatformtests.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/unittests/baseplatformtests.py b/unittests/baseplatformtests.py
index 377032192..0ac9c9cf0 100644
--- a/unittests/baseplatformtests.py
+++ b/unittests/baseplatformtests.py
@@ -42,7 +42,6 @@ from run_tests import (
# e.g. for assertXXX helpers.
__unittest = True
-@mock.patch.dict(os.environ)
class BasePlatformTests(TestCase):
prefix = '/usr'
libdir = 'lib'
@@ -87,9 +86,18 @@ class BasePlatformTests(TestCase):
# VS doesn't have a stable output when no changes are done
# XCode backend is untested with unit tests, help welcome!
cls.no_rebuild_stdout = [f'UNKNOWN BACKEND {cls.backend.name!r}']
+
+ cls.env_patch = mock.patch.dict(os.environ)
+ cls.env_patch.start()
+
os.environ['COLUMNS'] = '80'
os.environ['PYTHONIOENCODING'] = 'utf8'
+ @classmethod
+ def tearDownClass(cls) -> None:
+ super().tearDownClass()
+ cls.env_patch.stop()
+
def setUp(self):
super().setUp()
self.meson_native_files = []