Gentoo Archives: gentoo-commits

From: Arfrever Frehtes Taifersar Arahesis <arfrever@××××××.org>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/tests/util/
Date: Sun, 02 Feb 2014 04:11:27
Message-Id: 1391314201.2411ec3a11ecf53cb1725c0282797d8d0e40ecbc.arfrever@gentoo
1 commit: 2411ec3a11ecf53cb1725c0282797d8d0e40ecbc
2 Author: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
3 AuthorDate: Sun Feb 2 04:10:01 2014 +0000
4 Commit: Arfrever Frehtes Taifersar Arahesis <arfrever <AT> apache <DOT> org>
5 CommitDate: Sun Feb 2 04:10:01 2014 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=2411ec3a
7
8 portage.tests.util.test_getconfig.GetConfigTestCase.testGetConfigSourceLex(): Embed contents of test files in test function itself.
9
10 ---
11 .../tests/util/make.conf.example.source_test | 6 ----
12 .../tests/util/make.conf.example.source_test_after | 7 -----
13 pym/portage/tests/util/test_getconfig.py | 33 +++++++++++++---------
14 3 files changed, 19 insertions(+), 27 deletions(-)
15
16 diff --git a/pym/portage/tests/util/make.conf.example.source_test b/pym/portage/tests/util/make.conf.example.source_test
17 deleted file mode 100644
18 index c0b1c16..0000000
19 --- a/pym/portage/tests/util/make.conf.example.source_test
20 +++ /dev/null
21 @@ -1,6 +0,0 @@
22 -# Copyright 1999-2014 Gentoo Foundation
23 -# Distributed under the terms of the GNU General Public License v2
24 -# Contains local system settings for Portage system
25 -
26 -# Test make.conf for variable expansion in source tokens.
27 -source "$PORTAGE_BASE_PATH/make.conf.example.source_test_after"
28
29 diff --git a/pym/portage/tests/util/make.conf.example.source_test_after b/pym/portage/tests/util/make.conf.example.source_test_after
30 deleted file mode 100644
31 index e41913e..0000000
32 --- a/pym/portage/tests/util/make.conf.example.source_test_after
33 +++ /dev/null
34 @@ -1,7 +0,0 @@
35 -# Copyright 1999-2014 Gentoo Foundation
36 -# Distributed under the terms of the GNU General Public License v2
37 -# Contains local system settings for Portage system
38 -
39 -# Test make.conf for variable expansion in source tokens.
40 -# We should see this variable in getconfig result
41 -PASSES_SOURCING_TEST="True"
42
43 diff --git a/pym/portage/tests/util/test_getconfig.py b/pym/portage/tests/util/test_getconfig.py
44 index f1584c5..e5fd60f 100644
45 --- a/pym/portage/tests/util/test_getconfig.py
46 +++ b/pym/portage/tests/util/test_getconfig.py
47 @@ -4,6 +4,7 @@
48 import tempfile
49
50 from portage import os
51 +from portage import shutil
52 from portage import _unicode_encode
53 from portage.const import PORTAGE_BASE_PATH
54 from portage.tests import TestCase
55 @@ -33,23 +34,27 @@ class GetConfigTestCase(TestCase):
56 self.assertEqual(d[k], v)
57
58 def testGetConfigSourceLex(self):
59 + try:
60 + tempdir = tempfile.mkdtemp()
61 + make_conf_file = os.path.join(tempdir, 'make.conf')
62 + with open(make_conf_file, 'w') as f:
63 + f.write('source "${DIR}/sourced_file"\n')
64 + sourced_file = os.path.join(tempdir, 'sourced_file')
65 + with open(sourced_file, 'w') as f:
66 + f.write('PASSES_SOURCING_TEST="True"\n')
67
68 - base = os.path.dirname(__file__)
69 - make_conf_file = os.path.join(base,
70 - 'make.conf.example.source_test')
71 + d = getconfig(make_conf_file, allow_sourcing=True, expand={"DIR": tempdir})
72
73 - d = getconfig(make_conf_file,
74 - allow_sourcing=True, expand={"PORTAGE_BASE_PATH" : base})
75 + # PASSES_SOURCING_TEST should exist in getconfig result.
76 + self.assertTrue(d is not None)
77 + self.assertEqual("True", d['PASSES_SOURCING_TEST'])
78
79 - # PASSES_SOURCING_TEST should exist in getconfig result
80 - self.assertTrue(d is not None)
81 - self.assertEqual("True", d['PASSES_SOURCING_TEST'])
82 -
83 - # With allow_sourcing : True and empty expand map, this should
84 - # Throw a FileNotFound exception
85 - self.assertRaisesMsg("An empty expand map should throw an exception",
86 - ParseError, getconfig, *(make_conf_file,),
87 - **{'allow_sourcing' : True, 'expand' : {}})
88 + # With allow_sourcing=True and empty expand map, this should
89 + # throw a FileNotFound exception.
90 + self.assertRaisesMsg("An empty expand map should throw an exception",
91 + ParseError, getconfig, make_conf_file, allow_sourcing=True, expand={})
92 + finally:
93 + shutil.rmtree(tempdir)
94
95 def testGetConfigProfileEnv(self):
96 # Test the mode which is used to parse /etc/env.d and /etc/profile.env.