changeset 5565e0736e7f in trytond:5.4
details: https://hg.tryton.org/trytond?cmd=changeset;node=5565e0736e7f
description:
Restore English language on tear down
The translations tests change the default language on setup and commit
the
change. So we must restore the initial state of the database at the end
of the
test case.
issue9702
review312521002
(grafted from c7a827a5f88bf95b73f15c1499e8a50766bbeedf)
diffstat:
trytond/ir/configuration.py | 16 ++++++++++++++++
trytond/tests/test_modelsql.py | 26 ++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 0 deletions(-)
diffs (59 lines):
diff -r f0c5c457d86d -r 5565e0736e7f trytond/ir/configuration.py
--- a/trytond/ir/configuration.py Sun Oct 18 20:25:28 2020 +0200
+++ b/trytond/ir/configuration.py Wed Oct 14 14:43:40 2020 +0200
@@ -29,3 +29,19 @@
language = config.get('database', 'language')
cls._get_language_cache.set(None, language)
return language
+
+ @classmethod
+ def create(cls, vlist):
+ records = super().create(vlist)
+ cls._get_language_cache.clear()
+ return records
+
+ @classmethod
+ def write(cls, *args):
+ super().write(*args)
+ cls._get_language_cache.clear()
+
+ @classmethod
+ def delete(cls, records):
+ super().delete(records)
+ cls._get_language_cache.clear()
diff -r f0c5c457d86d -r 5565e0736e7f trytond/tests/test_modelsql.py
--- a/trytond/tests/test_modelsql.py Sun Oct 18 20:25:28 2020 +0200
+++ b/trytond/tests/test_modelsql.py Wed Oct 14 14:43:40 2020 +0200
@@ -556,6 +556,32 @@
Transaction().commit()
+ @classmethod
+ def tearDownClass(cls):
+ super().tearDownClass()
+ cls.restore_language()
+
+ @classmethod
+ @with_transaction()
+ def restore_language(cls):
+ pool = Pool()
+ Language = pool.get('ir.lang')
+ Configuration = pool.get('ir.configuration')
+
+ english, = Language.search([('code', '=', 'en')])
+ english.translatable = True
+ english.save()
+
+ config = Configuration(1)
+ config.language = 'en'
+ config.save()
+
+ Language.write(Language.search([('code', '!=', 'en')]), {
+ 'translatable': False,
+ })
+
+ Transaction().commit()
+
@with_transaction()
def test_create_default_language(self):
"Test create default language"