[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[dak/master 16/23] Use a custom dak.conf during tests - now we can import daklib.utils.



Signed-off-by: Chris Lamb <lamby@debian.org>
---
 daklib/utils.py         |    3 ++-
 tests/base_test.py      |    5 +++++
 2 files changed, 7 insertions(+), 1 deletions(-)
 create mode 100644 tests/fixtures/dak.conf

diff --git a/daklib/utils.py b/daklib/utils.py
index 0528748..1fc1d47 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 b116e49..255e71b 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 0000000..e69de29
-- 
1.6.3.3



Reply to: