diff --git a/canaille/backends/ldap/ldapobject.py b/canaille/backends/ldap/ldapobject.py index 4bbbd155..da837b25 100644 --- a/canaille/backends/ldap/ldapobject.py +++ b/canaille/backends/ldap/ldapobject.py @@ -477,4 +477,7 @@ def save(self): def delete(self): conn = Backend.get().connection - conn.delete_s(self.dn) + try: + conn.delete_s(self.dn) + except ldap.NO_SUCH_OBJECT: + pass diff --git a/tests/backends/test_models.py b/tests/backends/test_models.py index 02fb75a1..02b3d0ff 100644 --- a/tests/backends/test_models.py +++ b/tests/backends/test_models.py @@ -61,6 +61,8 @@ def test_model_lifecycle(testclient, backend): assert not models.User.query(id=user.id) assert not models.User.get(id=user.id) + user.delete() + def test_model_attribute_edition(testclient, backend): user = models.User(