1 |
For tests, override portage.const.EPREFIX in order to avoid unwanted |
2 |
access to /etc/portage. This override may seem evil, but it is a |
3 |
convenient way to simulate a prefix install, and it is reasonable to do |
4 |
this because tests should be self-contained such that the "real" value |
5 |
of portage.const.EPREFIX is entirely irrelevant. |
6 |
|
7 |
X-Gentoo-Bug: 492932 |
8 |
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=492932 |
9 |
--- |
10 |
pym/portage/tests/dbapi/test_fakedbapi.py | 11 ++++++++++- |
11 |
pym/portage/tests/resolver/ResolverPlayground.py | 6 ++++++ |
12 |
2 files changed, 16 insertions(+), 1 deletion(-) |
13 |
|
14 |
diff --git a/pym/portage/tests/dbapi/test_fakedbapi.py b/pym/portage/tests/dbapi/test_fakedbapi.py |
15 |
index 7713563..4f718e0 100644 |
16 |
--- a/pym/portage/tests/dbapi/test_fakedbapi.py |
17 |
+++ b/pym/portage/tests/dbapi/test_fakedbapi.py |
18 |
@@ -1,8 +1,9 @@ |
19 |
-# Copyright 2011-2013 Gentoo Foundation |
20 |
+# Copyright 2011-2014 Gentoo Foundation |
21 |
# Distributed under the terms of the GNU General Public License v2 |
22 |
|
23 |
import tempfile |
24 |
|
25 |
+import portage |
26 |
from portage import os |
27 |
from portage import shutil |
28 |
from portage.dbapi.virtual import fakedbapi |
29 |
@@ -49,6 +50,14 @@ class TestFakedbapi(TestCase): |
30 |
env = { |
31 |
"PORTAGE_REPOSITORIES": "[DEFAULT]\nmain-repo = test_repo\n[test_repo]\nlocation = %s" % test_repo |
32 |
} |
33 |
+ |
34 |
+ # Tests may override portage.const.EPREFIX in order to |
35 |
+ # simulate a prefix installation. It's reasonable to do |
36 |
+ # this because tests should be self-contained such that |
37 |
+ # the "real" value of portage.const.EPREFIX is entirely |
38 |
+ # irrelevant (see bug #492932). |
39 |
+ portage.const.EPREFIX = tempdir |
40 |
+ |
41 |
fakedb = fakedbapi(settings=config(config_profile_path="", |
42 |
env=env, eprefix=tempdir)) |
43 |
for cpv, metadata in packages: |
44 |
diff --git a/pym/portage/tests/resolver/ResolverPlayground.py b/pym/portage/tests/resolver/ResolverPlayground.py |
45 |
index 0be5d81..fb6a951 100644 |
46 |
--- a/pym/portage/tests/resolver/ResolverPlayground.py |
47 |
+++ b/pym/portage/tests/resolver/ResolverPlayground.py |
48 |
@@ -72,6 +72,12 @@ class ResolverPlayground(object): |
49 |
self.eprefix = normalize_path(tempfile.mkdtemp()) |
50 |
else: |
51 |
self.eprefix = normalize_path(eprefix) |
52 |
+ |
53 |
+ # Tests may override portage.const.EPREFIX in order to |
54 |
+ # simulate a prefix installation. It's reasonable to do |
55 |
+ # this because tests should be self-contained such that |
56 |
+ # the "real" value of portage.const.EPREFIX is entirely |
57 |
+ # irrelevant (see bug #492932). |
58 |
portage.const.EPREFIX = self.eprefix.rstrip(os.sep) |
59 |
|
60 |
self.eroot = self.eprefix + os.sep |
61 |
-- |
62 |
2.0.4 |