portage.tests.util.test_getconfig.GetConfigTestCase.testGetConfigSourceLex(): Embed contents of test files in test function itself.
diff --git a/pym/portage/tests/util/make.conf.example.source_test b/pym/portage/tests/util/make.conf.example.source_test
deleted file mode 100644
index c0b1c16..0000000
--- a/pym/portage/tests/util/make.conf.example.source_test
+++ /dev/null
@@ -1,6 +0,0 @@
-# Copyright 1999-2014 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# Contains local system settings for Portage system
-
-# Test make.conf for variable expansion in source tokens.
-source "$PORTAGE_BASE_PATH/make.conf.example.source_test_after"
diff --git a/pym/portage/tests/util/make.conf.example.source_test_after b/pym/portage/tests/util/make.conf.example.source_test_after
deleted file mode 100644
index e41913e..0000000
--- a/pym/portage/tests/util/make.conf.example.source_test_after
+++ /dev/null
@@ -1,7 +0,0 @@
-# Copyright 1999-2014 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# Contains local system settings for Portage system
-
-# Test make.conf for variable expansion in source tokens.
-# We should see this variable in getconfig result
-PASSES_SOURCING_TEST="True"
diff --git a/pym/portage/tests/util/test_getconfig.py b/pym/portage/tests/util/test_getconfig.py
index f1584c5..e5fd60f 100644
--- a/pym/portage/tests/util/test_getconfig.py
+++ b/pym/portage/tests/util/test_getconfig.py
@@ -4,6 +4,7 @@
import tempfile
from portage import os
+from portage import shutil
from portage import _unicode_encode
from portage.const import PORTAGE_BASE_PATH
from portage.tests import TestCase
@@ -33,23 +34,27 @@
self.assertEqual(d[k], v)
def testGetConfigSourceLex(self):
+ try:
+ tempdir = tempfile.mkdtemp()
+ make_conf_file = os.path.join(tempdir, 'make.conf')
+ with open(make_conf_file, 'w') as f:
+ f.write('source "${DIR}/sourced_file"\n')
+ sourced_file = os.path.join(tempdir, 'sourced_file')
+ with open(sourced_file, 'w') as f:
+ f.write('PASSES_SOURCING_TEST="True"\n')
- base = os.path.dirname(__file__)
- make_conf_file = os.path.join(base,
- 'make.conf.example.source_test')
+ d = getconfig(make_conf_file, allow_sourcing=True, expand={"DIR": tempdir})
- d = getconfig(make_conf_file,
- allow_sourcing=True, expand={"PORTAGE_BASE_PATH" : base})
+ # PASSES_SOURCING_TEST should exist in getconfig result.
+ self.assertTrue(d is not None)
+ self.assertEqual("True", d['PASSES_SOURCING_TEST'])
- # PASSES_SOURCING_TEST should exist in getconfig result
- self.assertTrue(d is not None)
- self.assertEqual("True", d['PASSES_SOURCING_TEST'])
-
- # With allow_sourcing : True and empty expand map, this should
- # Throw a FileNotFound exception
- self.assertRaisesMsg("An empty expand map should throw an exception",
- ParseError, getconfig, *(make_conf_file,),
- **{'allow_sourcing' : True, 'expand' : {}})
+ # With allow_sourcing=True and empty expand map, this should
+ # throw a FileNotFound exception.
+ self.assertRaisesMsg("An empty expand map should throw an exception",
+ ParseError, getconfig, make_conf_file, allow_sourcing=True, expand={})
+ finally:
+ shutil.rmtree(tempdir)
def testGetConfigProfileEnv(self):
# Test the mode which is used to parse /etc/env.d and /etc/profile.env.