Skip to content

Commit e9fea0f

Browse files
dcbakernirbheek
authored andcommitted
unittests: mock os.environ before mucking with it
1 parent 80ec7ec commit e9fea0f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

run_unittests.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3211,6 +3211,7 @@ def test_pkgconfig_static(self):
32113211
os.unlink(fname)
32123212

32133213
@skipIfNoPkgconfig
3214+
@mock.patch.dict(os.environ)
32143215
def test_pkgconfig_gen_escaping(self):
32153216
testdir = os.path.join(self.common_test_dir, '47 pkgconfig-gen')
32163217
prefix = '/usr/with spaces'
@@ -5443,6 +5444,7 @@ def setUp(self):
54435444
self.platform_test_dir = os.path.join(self.src_root, 'test cases/windows')
54445445

54455446
@unittest.skipIf(is_cygwin(), 'Test only applicable to Windows')
5447+
@mock.patch.dict(os.environ)
54465448
def test_find_program(self):
54475449
'''
54485450
Test that Windows-specific edge-cases in find_program are functioning
@@ -5894,6 +5896,7 @@ def test_pic(self):
58945896
compdb = self.get_compdb()
58955897
self.assertNotIn('-fPIC', compdb[0]['command'])
58965898

5899+
@mock.patch.dict(os.environ)
58975900
def test_pkgconfig_gen(self):
58985901
'''
58995902
Test that generated pkg-config files can be found and have the correct
@@ -5931,7 +5934,6 @@ def test_pkgconfig_gen_deps(self):
59315934
self.init(testdir, override_envvars={'PKG_CONFIG_LIBDIR': privatedir1})
59325935
privatedir2 = self.privatedir
59335936

5934-
os.environ
59355937
env = {
59365938
'PKG_CONFIG_LIBDIR': os.pathsep.join([privatedir1, privatedir2]),
59375939
'PKG_CONFIG_SYSTEM_LIBRARY_PATH': '/usr/lib',
@@ -5992,6 +5994,7 @@ def test_pkgconfig_gen_deps(self):
59925994
content = f.read()
59935995
self.assertNotIn('-lstat2', content)
59945996

5997+
@mock.patch.dict(os.environ)
59955998
def test_pkgconfig_uninstalled(self):
59965999
testdir = os.path.join(self.common_test_dir, '47 pkgconfig-gen')
59976000
self.init(testdir)

0 commit comments

Comments
 (0)