changeset dfec19a7185b in trytond:4.6 details: https://hg.tryton.org/trytond?cmd=changeset;node=dfec19a7185b 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 99277d8139cb -r dfec19a7185b trytond/tests/test_tryton.py --- a/trytond/tests/test_tryton.py Mon Nov 12 23:22:13 2018 +0100 +++ b/trytond/tests/test_tryton.py Wed Nov 07 19:02:34 2018 +0100 @@ -194,10 +194,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