summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSebastian Heinlein <devel@glatzor.de>2012-04-17 20:36:02 +0200
committerSebastian Heinlein <devel@glatzor.de>2012-04-17 20:36:02 +0200
commit89e3cd4d1141fea8ecb5b8828cde622c9bf12649 (patch)
tree202d2f047dc5b316dc3b9fa6804673e256932591 /tests
parentef6911924b5e1647dd2c57649478ebc7501f4682 (diff)
downloadpython-apt-89e3cd4d1141fea8ecb5b8828cde622c9bf12649.tar.gz
Add a regression test
Diffstat (limited to 'tests')
-rw-r--r--tests/test_lp659438.py68
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/test_lp659438.py b/tests/test_lp659438.py
new file mode 100644
index 00000000..25a6278f
--- /dev/null
+++ b/tests/test_lp659438.py
@@ -0,0 +1,68 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""Regression test for LP: #981896, LP: #659438"""
+# Copyright (C) 2012 Sebastian Heinlein <devel@glatzor.de>
+#
+# Licensed under the GNU General Public License Version 2
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# Licensed under the GNU General Public License Version 2
+
+__author__ = "Sebastian Heinlein <devel@glatzor.de>"
+
+import os
+import shutil
+import tempfile
+import unittest
+
+import apt_pkg
+import apt
+
+
+class RegressionTestCase(unittest.TestCase):
+
+ """Test suite for LP: #981896, LP: #659438
+ 'Cannot locate a file for package X'
+ """
+
+ def setUp(self):
+ apt_pkg.init_config()
+ chroot_path = tempfile.mkdtemp()
+ self.addCleanup(lambda: shutil.rmtree(chroot_path))
+ # Create a damaged status file
+ self.cache = apt.cache.Cache(rootdir=chroot_path)
+ with open(apt_pkg.config.find_file("Dir::State::status"),
+ "a") as status:
+ status.write("""Package: abrowser
+Status: install reinstreq half-installed
+Priority: optional
+Section: admin
+Version: 3.6.9+build1+nobinonly-0ubuntu1""")
+ sources_list_path = apt_pkg.config.find_file("Dir::Etc::sourcelist")
+ repo_path = os.path.abspath("./data/test-repo")
+ with open(sources_list_path, "w") as sources_list:
+ sources_list.write("deb copy:%s /\n" % repo_path)
+ # os.makedirs(os.path.join(chroot_path, "etc/apt/sources.list.d/"))
+ self.cache.update(sources_list=sources_list_path)
+ self.cache.open()
+
+ def test_survive_reqreinst(self):
+ """Test that we survive a package in require reinstallation state"""
+ self.assertEqual(self.cache.required_download, 82324L)
+
+if __name__ == "__main__":
+ unittest.main()
+
+# vim: ts=4 et sts=4