From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id D01DB1389E2 for ; Sat, 20 Dec 2014 21:11:53 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id E28BAE09E4; Sat, 20 Dec 2014 21:11:52 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 72308E09DE for ; Sat, 20 Dec 2014 21:11:52 +0000 (UTC) Received: from localhost.localdomain (ip70-181-96-121.oc.oc.cox.net [70.181.96.121]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: zmedico) by smtp.gentoo.org (Postfix) with ESMTPSA id 6E48634067D; Sat, 20 Dec 2014 21:11:51 +0000 (UTC) From: Zac Medico To: gentoo-portage-dev@lists.gentoo.org Cc: Zac Medico Subject: [gentoo-portage-dev] [PATCH] TestFakedbapi: override EPREFIX for bug #492932 Date: Sat, 20 Dec 2014 13:11:11 -0800 Message-Id: <1419109871-21962-1-git-send-email-zmedico@gentoo.org> X-Mailer: git-send-email 2.0.4 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-portage-dev@lists.gentoo.org Reply-to: gentoo-portage-dev@lists.gentoo.org X-Archives-Salt: 9d25f72e-7df9-4c8f-be57-dd6951d50cff X-Archives-Hash: d93b0baeae1c89235d9f551d68f58f24 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