summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2014-01-06 16:11:28 +0100
committerJulian Andres Klode <jak@debian.org>2014-01-06 16:20:36 +0100
commit16741d48bf49b05c54159c9c39ed7dd562f1f55f (patch)
treeef6826e4f41bdbef333f290f0f73613a943e9474
parent1ef0777d668a6bde0eb592928996a08570864c3f (diff)
downloadpython-apt-16741d48bf49b05c54159c9c39ed7dd562f1f55f.tar.gz
apt/package.py: Fix BaseDependency.__dstr.__ne__()
It turns out I missed this. Just simplify it to return not self.__eq__(other). Also add a test case for it. Reported-by: Michael Schaller <michael@5challer.de>
-rw-r--r--apt/package.py2
-rw-r--r--tests/test_deps.py28
2 files changed, 29 insertions, 1 deletions
diff --git a/apt/package.py b/apt/package.py
index 78b10af4..5d122968 100644
--- a/apt/package.py
+++ b/apt/package.py
@@ -78,7 +78,7 @@ class BaseDependency(object):
return str.__eq__(self, other) or str.__eq__(2 * self, other)
def __ne__(self, other):
- return str.__eq__(self, other) and str.__ne__(2 * self, other)
+ return not self.__eq__(other)
def __init__(self, name, rel, ver, pre, rawtype=None):
self.name = name
diff --git a/tests/test_deps.py b/tests/test_deps.py
index e9a75ee2..399bb9ba 100644
--- a/tests/test_deps.py
+++ b/tests/test_deps.py
@@ -9,6 +9,7 @@
import unittest
import apt_pkg
+import apt.package
class TestDependencies(unittest.TestCase):
@@ -110,6 +111,33 @@ class TestDependencies(unittest.TestCase):
self.assertEqual(len(depends_this), len(depends_this_too), 1)
self.assertEqual(len(depends_other), len(depends_other_too), 0)
+ def test_dstr(self):
+ """Test apt.package.BaseDependency.__dstr"""
+ dstr = apt.package.BaseDependency._BaseDependency__dstr
+ self.assertEqual(dstr("<"), "<<")
+ self.assertEqual(dstr("<"), "<")
+ self.assertEqual("<<", dstr("<"))
+ self.assertEqual("<", dstr("<"))
+ self.assertEqual(dstr(">"), ">>")
+ self.assertEqual(dstr(">"), ">")
+ self.assertEqual(">>", dstr(">"))
+ self.assertEqual(">", dstr(">"))
+ self.assertNotEqual(dstr(">"), "<")
+ self.assertNotEqual(dstr(">"), "<=")
+ self.assertNotEqual(dstr(">"), "<<")
+ self.assertNotEqual(dstr(">"), "!=")
+ self.assertNotEqual(dstr(">"), "=")
+ self.assertNotEqual(dstr(">"), "<")
+ self.assertNotEqual(dstr(">"), "<=")
+ self.assertNotEqual(dstr(">"), "<<")
+ self.assertNotEqual(dstr(">"), "!=")
+ self.assertNotEqual(dstr(">"), "=")
+ self.assertFalse(dstr("<") != "<")
+ self.assertFalse(dstr("<") != "<<")
+ self.assertFalse(dstr(">") != ">")
+ self.assertFalse(dstr(">") != ">>")
+
+
def testParseDepends(self):
"""dependencies: Test apt_pkg.ParseDepends()."""
if not hasattr(apt_pkg, 'ParseDepends'):