changeset 9bacbef1c8fc in trytond:4.2
details: https://hg.tryton.org/trytond?cmd=changeset;node=9bacbef1c8fc
description:
Ensure to rollback and clean cache on exception
Exception raised in a test decorated by with_transaction should always
clear
the cache to avoid leaking to other tests.
issue7829
review64471002
(grafted from a1b67354c6243f9066c9ff6eadef96f5838fa8f6)
diffstat:
trytond/tests/test_tryton.py | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diffs (20 lines):
diff -r 563a9f8176f2 -r 9bacbef1c8fc trytond/tests/test_tryton.py
--- a/trytond/tests/test_tryton.py Mon Nov 12 23:24:40 2018 +0100
+++ b/trytond/tests/test_tryton.py Wed Nov 07 19:02:34 2018 +0100
@@ -163,10 +163,12 @@
def wrapper(*args, **kwargs):
transaction = Transaction()
with transaction.start(DB_NAME, user, context=context):
- result = func(*args, **kwargs)
- transaction.rollback()
- # Drop the cache as the transaction is rollbacked
- Cache.drop(DB_NAME)
+ try:
+ result = func(*args, **kwargs)
+ finally:
+ transaction.rollback()
+ # Drop the cache as the transaction is rollbacked
+ Cache.drop(DB_NAME)
return result
return wrapper
return decorator