changeset fffbeae5756f in trytond:5.4
details: https://hg.tryton.org/trytond?cmd=changeset;node=fffbeae5756f
description:
Test memory cache with committed transaction as current
The tests did not correspond to a proper use case because the
transaction
committed was not the current transaction. So this could lead to wrong
cache
being reset and wrong cache being tested.
issue8502
review289171002
(grafted from bcf8d6f2fff18d01a1b8ae614206780a43181a32)
diffstat:
trytond/tests/test_cache.py | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
diffs (24 lines):
diff -r 4c3696a31ce1 -r fffbeae5756f trytond/tests/test_cache.py
--- a/trytond/tests/test_cache.py Sun Feb 02 16:54:31 2020 +0100
+++ b/trytond/tests/test_cache.py Mon Feb 10 23:13:26 2020 +0100
@@ -93,16 +93,15 @@
cache.set('foo', 'baz')
self.assertEqual(cache.get('foo'), 'baz')
- Transaction().set_current_transaction(transaction1)
- self.addCleanup(transaction1.stop)
- self.assertEqual(cache.get('foo'), 'bar')
+ with Transaction().set_current_transaction(transaction1):
+ self.assertEqual(cache.get('foo'), 'bar')
transaction2.commit()
for n in range(10):
- if cache.get('foo') is None:
+ if cache.get('foo') == 'baz':
break
self.wait_cache_sync()
- self.assertEqual(cache.get('foo'), None)
+ self.assertEqual(cache.get('foo'), 'baz')
def test_memory_cache_nested_transactions(self):
"Test MemoryCache with nested transactions"