summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Kämpf <kkaempf@suse.de>2010-12-06 14:41:23 +0100
committerKlaus Kämpf <kkaempf@suse.de>2010-12-06 14:41:23 +0100
commita35529dc50aa907f9f1c3a4f05158bc7f4debbc0 (patch)
tree2b479391ec303eeb100b8fb2da499280f1b2f8a8
parent75f229e2e5fe0eb858aa71819150f27c16f95627 (diff)
downloadlibzypp-bindings-a35529dc50aa907f9f1c3a4f05158bc7f4debbc0.tar.gz
libzypp-bindings-a35529dc50aa907f9f1c3a4f05158bc7f4debbc0.tar.bz2
libzypp-bindings-a35529dc50aa907f9f1c3a4f05158bc7f4debbc0.zip
Fix Problems iterator in Python
-rw-r--r--swig/Resolver.i23
-rw-r--r--swig/python/tests/CMakeLists.txt3
-rw-r--r--swig/python/tests/problems.py21
3 files changed, 43 insertions, 4 deletions
diff --git a/swig/Resolver.i b/swig/Resolver.i
index 7e9f2e1..2d1f402 100644
--- a/swig/Resolver.i
+++ b/swig/Resolver.i
@@ -2,9 +2,26 @@
%template(StringList) std::list<std::string>;
#endif
+%include <zypp/ProblemTypes.h>
+%include <zypp/ResolverProblem.h>
+%include <zypp/ProblemSolution.h>
%include <zypp/Resolver.h>
+
namespace zypp
{
-typedef intrusive_ptr<Resolver> Resolver_Ptr;
-%template(Resolver_Ptr) intrusive_ptr<Resolver>;
-} \ No newline at end of file
+ typedef intrusive_ptr< Resolver > Resolver_Ptr;
+ %template(Resolver_Ptr) intrusive_ptr<Resolver>;
+
+#ifndef SWIGRUBY
+ /* swig generates wrong code (>> instead of > > for template type)
+ * in Ruby
+ */
+
+ typedef ::boost::intrusive_ptr< ResolverProblem > ResolverProblem_Ptr;
+ %template(ResolverProblem_Ptr) ::boost::intrusive_ptr< ResolverProblem >;
+ typedef std::list< ResolverProblem_Ptr > ResolverProblemList;
+ %template(ResolverProblemList) ::std::list< ResolverProblem_Ptr >;
+
+#endif
+}
+
diff --git a/swig/python/tests/CMakeLists.txt b/swig/python/tests/CMakeLists.txt
index 8424cc0..e35d3ac 100644
--- a/swig/python/tests/CMakeLists.txt
+++ b/swig/python/tests/CMakeLists.txt
@@ -6,4 +6,5 @@ ENABLE_TESTING()
ADD_TEST(bindings_python_loading python ${CMAKE_CURRENT_SOURCE_DIR}/loading.py)
ADD_TEST(bindings_python_repoinfo python ${CMAKE_CURRENT_SOURCE_DIR}/repoinfo.py)
-ADD_TEST(bindings_python_commit_callbacks python ${CMAKE_CURRENT_SOURCE_DIR}/commit_callbacks.py) \ No newline at end of file
+ADD_TEST(bindings_python_commit_callbacks python ${CMAKE_CURRENT_SOURCE_DIR}/commit_callbacks.py)
+ADD_TEST(bindings_python_problems python ${CMAKE_CURRENT_SOURCE_DIR}/problems.py)
diff --git a/swig/python/tests/problems.py b/swig/python/tests/problems.py
new file mode 100644
index 0000000..0406290
--- /dev/null
+++ b/swig/python/tests/problems.py
@@ -0,0 +1,21 @@
+import unittest
+
+import os
+cwd = os.path.abspath(os.path.dirname(__file__))
+
+import sys
+sys.path.insert(0, cwd + "/../../../build/swig/python")
+
+class TestSequenceFunctions(unittest.TestCase):
+
+ def testproblems(self):
+ import zypp
+ Z = zypp.ZYppFactory.instance().getZYpp()
+ assert Z
+ if not Z.resolver().resolvePool():
+ for problem in Z.resolver().problems():
+ print "Problem %s" % problem.description()
+# raise "Solver Error"
+
+if __name__ == '__main__':
+ unittest.main()