summaryrefslogtreecommitdiffstats
path: root/tests/testcommon.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/testcommon.py')
-rw-r--r--tests/testcommon.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/testcommon.py b/tests/testcommon.py
new file mode 100644
index 0000000..29917a7
--- /dev/null
+++ b/tests/testcommon.py
@@ -0,0 +1,30 @@
+"""Common testing stuff"""
+
+import os
+import unittest
+
+import apt_pkg
+
+
+class TestCase(unittest.TestCase):
+ """Base class for python-apt unittests"""
+
+ def setUp(self):
+ self.resetConfig()
+
+ def resetConfig(self):
+ apt_pkg.config.clear("")
+ for key in apt_pkg.config.list():
+ apt_pkg.config.clear(key)
+
+ # Avoid loading any host config files
+ os.unsetenv("APT_CONFIG")
+ apt_pkg.config["Dir::Etc::main"] = "/dev/null"
+ apt_pkg.config["Dir::Etc::parts"] = "/dev/null"
+
+ apt_pkg.init_config()
+ apt_pkg.init_system()
+
+ # Restore default values
+ apt_pkg.config["Dir::Etc::main"] = "apt.conf"
+ apt_pkg.config["Dir::Etc::parts"] = "apt.conf.d"