public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Zac Medico <zmedico@gentoo.org>
To: gentoo-portage-dev@lists.gentoo.org
Cc: Zac Medico <zmedico@gentoo.org>
Subject: [gentoo-portage-dev] [PATCH] TestFakedbapi: override EPREFIX for bug #492932
Date: Sat, 20 Dec 2014 13:11:11 -0800	[thread overview]
Message-ID: <1419109871-21962-1-git-send-email-zmedico@gentoo.org> (raw)

For tests, override portage.const.EPREFIX in order to avoid unwanted
access to /etc/portage. This override may seem evil, but it is a
convenient way to simulate a prefix install, and it is reasonable to do
this because tests should be self-contained such that the "real" value
of portage.const.EPREFIX is entirely irrelevant.

X-Gentoo-Bug: 492932
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=492932
---
 pym/portage/tests/dbapi/test_fakedbapi.py        | 11 ++++++++++-
 pym/portage/tests/resolver/ResolverPlayground.py |  6 ++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/pym/portage/tests/dbapi/test_fakedbapi.py b/pym/portage/tests/dbapi/test_fakedbapi.py
index 7713563..4f718e0 100644
--- a/pym/portage/tests/dbapi/test_fakedbapi.py
+++ b/pym/portage/tests/dbapi/test_fakedbapi.py
@@ -1,8 +1,9 @@
-# Copyright 2011-2013 Gentoo Foundation
+# Copyright 2011-2014 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 import tempfile
 
+import portage
 from portage import os
 from portage import shutil
 from portage.dbapi.virtual import fakedbapi
@@ -49,6 +50,14 @@ class TestFakedbapi(TestCase):
 			env = {
 				"PORTAGE_REPOSITORIES": "[DEFAULT]\nmain-repo = test_repo\n[test_repo]\nlocation = %s" % test_repo
 			}
+
+			# Tests may override portage.const.EPREFIX in order to
+			# simulate a prefix installation. It's reasonable to do
+			# this because tests should be self-contained such that
+			# the "real" value of portage.const.EPREFIX is entirely
+			# irrelevant (see bug #492932).
+			portage.const.EPREFIX = tempdir
+
 			fakedb = fakedbapi(settings=config(config_profile_path="",
 				env=env, eprefix=tempdir))
 			for cpv, metadata in packages:
diff --git a/pym/portage/tests/resolver/ResolverPlayground.py b/pym/portage/tests/resolver/ResolverPlayground.py
index 0be5d81..fb6a951 100644
--- a/pym/portage/tests/resolver/ResolverPlayground.py
+++ b/pym/portage/tests/resolver/ResolverPlayground.py
@@ -72,6 +72,12 @@ class ResolverPlayground(object):
 			self.eprefix = normalize_path(tempfile.mkdtemp())
 		else:
 			self.eprefix = normalize_path(eprefix)
+
+		# Tests may override portage.const.EPREFIX in order to
+		# simulate a prefix installation. It's reasonable to do
+		# this because tests should be self-contained such that
+		# the "real" value of portage.const.EPREFIX is entirely
+		# irrelevant (see bug #492932).
 		portage.const.EPREFIX = self.eprefix.rstrip(os.sep)
 
 		self.eroot = self.eprefix + os.sep
-- 
2.0.4



             reply	other threads:[~2014-12-20 21:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-20 21:11 Zac Medico [this message]
2015-01-17 19:16 ` [gentoo-portage-dev] Re: [PATCH] TestFakedbapi: override EPREFIX for bug #492932 Zac Medico
2015-01-18 16:54   ` Brian Dolbec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1419109871-21962-1-git-send-email-zmedico@gentoo.org \
    --to=zmedico@gentoo.org \
    --cc=gentoo-portage-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox