From 7037cd22ff2839d1935a7d80ffec7590cb2445ce Mon Sep 17 00:00:00 2001
From: Manuel Guenther <manuel.guenther@idiap.ch>
Date: Fri, 17 Apr 2015 13:00:02 +0200
Subject: [PATCH] Added test for Repr function

---
 bob/io/base/hdf5.cpp     | 2 ++
 bob/io/base/test_hdf5.py | 4 ++++
 2 files changed, 6 insertions(+)

diff --git a/bob/io/base/hdf5.cpp b/bob/io/base/hdf5.cpp
index cd96351..d909e54 100644
--- a/bob/io/base/hdf5.cpp
+++ b/bob/io/base/hdf5.cpp
@@ -166,7 +166,9 @@ BOB_CATCH_MEMBER("hdf5 constructor", -1)
 
 
 static PyObject* PyBobIoHDF5File_repr(PyBobIoHDF5FileObject* self) {
+BOB_TRY
   return PyString_FromFormat("%s(filename='%s')", Py_TYPE(self)->tp_name, self->f->filename().c_str());
+BOB_CATCH_MEMBER("__repr__", 0)
 }
 
 
diff --git a/bob/io/base/test_hdf5.py b/bob/io/base/test_hdf5.py
index 39ef7d1..376e265 100644
--- a/bob/io/base/test_hdf5.py
+++ b/bob/io/base/test_hdf5.py
@@ -458,6 +458,7 @@ def test_copy_constructor():
     assert hdf5.filename != deep.filename
     assert hdf5.keys() != deep.keys()
     assert hdf5.cwd != deep.cwd
+    assert str(shallow)
 
     hdf5.cd("..")
 
@@ -475,6 +476,9 @@ def test_copy_constructor():
     def test_filename():
       fn = shallow.filename
     nose.tools.assert_raises(RuntimeError, test_filename)
+    def test_repr():
+      fn = str(shallow)
+    nose.tools.assert_raises(RuntimeError, test_repr)
 
   finally:
     os.unlink(tmpname)
-- 
GitLab