[entities / test] Move cache clearing to assert* method
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 07 Dec 2017 11:04:18 +0100
changeset 2901 c5c5d8ea25b9
parent 2900 e0e34c11185e
child 2902 497653f15d88
[entities / test] Move cache clearing to assert* method it avoid forgetting it and is easier to grasp.
test/test_entities.py
--- a/test/test_entities.py	Mon Dec 11 15:13:39 2017 +0100
+++ b/test/test_entities.py	Thu Dec 07 11:04:18 2017 +0100
@@ -215,11 +215,13 @@
 class ITreeTC(CubicWebTC):
 
     def assertChildren(self, entity, expected_eids):
+        entity.cw_clear_all_caches()
         itree = entity.cw_adapt_to('ITreeBase')
         children = [x.eid for x in itree.iterchildren()]
         self.assertEqual(children, expected_eids)
 
     def assertParent(self, entity, expected_eid):
+        entity.cw_clear_all_caches()
         itree = entity.cw_adapt_to('ITreeBase')
         parent = itree.parent()
         if parent:
@@ -237,8 +239,6 @@
             bdo = create_data_object(transfer,
                                      reverse_seda_data_object_reference_id=do_ref)
             cnx.commit()
-            au.cw_clear_all_caches()
-            bdo.cw_clear_all_caches()
 
             self.assertChildren(transfer, [bdo.eid, au.eid])
             self.assertChildren(au, [])
@@ -248,8 +248,6 @@
 
             transfer.cw_set(simplified_profile=True)
             cnx.commit()
-            au.cw_clear_all_caches()
-            bdo.cw_clear_all_caches()
 
             self.assertChildren(transfer, [au.eid])
             self.assertChildren(au, [bdo.eid])