aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Piotr Jaroszyński <peper@gentoo.org> 2007-11-14 01:33:21 +0000
committerAvatar Piotr Jaroszyński <peper@gentoo.org> 2007-11-14 01:33:21 +0000
commit18115303e89e8ad5d5934c7dfdde9c671b57637e (patch)
tree094d493cdaa76270e849dc227424e2d221108e0e
parent57e078aec9546a4d3738eaaaf1f51bb061a8e2b8 (diff)
downloadpaludis-18115303e89e8ad5d5934c7dfdde9c671b57637e.tar.gz
paludis-18115303e89e8ad5d5934c7dfdde9c671b57637e.tar.xz
(python) Add __str__ to PackageID.
-rw-r--r--python/package_id.cc2
-rwxr-xr-xpython/package_id_TEST.py14
2 files changed, 11 insertions, 5 deletions
diff --git a/python/package_id.cc b/python/package_id.cc
index 16f0621..27fa688 100644
--- a/python/package_id.cc
+++ b/python/package_id.cc
@@ -115,6 +115,8 @@ void expose_package_id()
.def("__eq__", &py_eq<PackageID>)
.def("__ne__", &py_ne<PackageID>)
+
+ .def(bp::self_ns::str(bp::self))
;
/**
diff --git a/python/package_id_TEST.py b/python/package_id_TEST.py
index 83a798d..bcbda4c 100755
--- a/python/package_id_TEST.py
+++ b/python/package_id_TEST.py
@@ -64,15 +64,19 @@ class TestCase_01_PackageID(unittest.TestCase):
self.assertEquals(self.ipid.canonical_form(PackageIDCanonicalForm.VERSION), "1")
self.assertEquals(self.ipid.canonical_form(PackageIDCanonicalForm.NO_VERSION), "cat-one/pkg-one::installed")
- def test_08_find_metadata(self):
+ def test_08_str(self):
+ self.assertEquals(str(self.pid), "foo/bar-1.0::testrepo")
+ self.assertEquals(str(self.ipid), "cat-one/pkg-one-1::installed")
+
+ def test_09_find_metadata(self):
self.assert_(isinstance(self.pid.find_metadata("DEPEND"), MetadataDependencySpecTreeKey))
- def test_09_perform_action(self):
+ def test_10_perform_action(self):
self.pid.perform_action(PretendAction())
self.assertRaises(UnsupportedActionError, self.pid.perform_action, ConfigAction())
self.assertRaises(UnsupportedActionError, self.ipid.perform_action, PretendAction())
- def test_10_supports_action(self):
+ def test_11_supports_action(self):
self.assert_(self.pid.supports_action(SupportsFetchActionTest()))
self.assert_(self.pid.supports_action(SupportsInstallActionTest()))
self.assert_(self.pid.supports_action(SupportsFetchActionTest()))
@@ -89,11 +93,11 @@ class TestCase_01_PackageID(unittest.TestCase):
self.assert_(not self.ipid.supports_action(SupportsPretendActionTest()))
self.assert_(self.ipid.supports_action(SupportsConfigActionTest()))
- def test_11_masked(self):
+ def test_12_masked(self):
self.assert_(not self.pid.masked)
self.assert_(self.mpid.masked)
- def test_12_masks(self):
+ def test_13_masks(self):
mask = iter(self.mpid.masks).next()
self.assert_(isinstance(mask, UnacceptedMask))