[PATCH 06 of 18 seda] [entities / test] Move cache clearing to assert* method

Sylvain Thenault sylvain.thenault at logilab.fr
Mon Dec 11 16:53:38 CET 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1512641058 -3600
#      Thu Dec 07 11:04:18 2017 +0100
# Node ID e1fe9adc6a0fc9c213195d91e615b1f36709f906
# Parent  b8373601613d23251a4c399ccf22a251dbf99cbb
[entities / test] Move cache clearing to assert* method

it avoid forgetting it and is easier to grasp.

diff --git a/test/test_entities.py b/test/test_entities.py
--- a/test/test_entities.py
+++ b/test/test_entities.py
@@ -213,15 +213,17 @@ class PredicatesTC(CubicWebTC):
 
 
 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:
             parent_eid = parent.eid
         else:
@@ -235,23 +237,19 @@ class ITreeTC(CubicWebTC):
             do_ref = cnx.create_entity('SEDADataObjectReference',
                                        seda_data_object_reference=seq)
             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, [])
             self.assertParent(transfer, None)
             self.assertParent(au, transfer.eid)
             self.assertParent(bdo, transfer.eid)
 
             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])
             self.assertParent(transfer, None)
             self.assertParent(au, transfer.eid)


More information about the saem-devel mailing list