From: Chris Lamb Date: Sat, 31 Oct 2009 13:53:11 +0000 (+0000) Subject: Use a custom dak.conf during tests - now we can import daklib.utils. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=682635f59f5271a071418e1eb6ccf0c3b3247c28;p=dak Use a custom dak.conf during tests - now we can import daklib.utils. Signed-off-by: Chris Lamb --- diff --git a/daklib/utils.py b/daklib/utils.py index 05287483..1fc1d477 100644 --- a/daklib/utils.py +++ b/daklib/utils.py @@ -1504,7 +1504,8 @@ def get_changes_files(from_dir): apt_pkg.init() Cnf = apt_pkg.newConfiguration() -apt_pkg.ReadConfigFileISC(Cnf,default_config) +if not os.getenv("DAK_TEST"): + apt_pkg.ReadConfigFileISC(Cnf,default_config) if which_conf_file() != default_config: apt_pkg.ReadConfigFileISC(Cnf,which_conf_file()) diff --git a/tests/base_test.py b/tests/base_test.py index b116e498..255e71b0 100644 --- a/tests/base_test.py +++ b/tests/base_test.py @@ -1,13 +1,18 @@ +import os import sys import unittest from os.path import abspath, dirname, join DAK_ROOT_DIR = dirname(dirname(abspath(__file__))) +DAK_TEST_FIXTURES = join(DAK_ROOT_DIR, 'tests', 'fixtures') class DakTestCase(unittest.TestCase): def setUp(self): pass +os.environ['DAK_TEST'] = '1' +os.environ['DAK_CONFIG'] = join(DAK_TEST_FIXTURES, 'dak.conf') + if DAK_ROOT_DIR not in sys.path: sys.path.insert(0, DAK_ROOT_DIR) diff --git a/tests/fixtures/dak.conf b/tests/fixtures/dak.conf new file mode 100644 index 00000000..e69de29b