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
This commit is contained in:
1 parent
457910b012
commit
ab14e12f1f
2 files changed
+42
No files matched your search
@@ -31,3 +31,19 @@ class Configuration(ModelSingleton, ModelSQL):
|
||||
def check(self):
|
||||
"Check configuration coherence on pool initialisation"
|
||||
pass
|
||||
|
||||
@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()
|
||||
@@ -555,6 +555,32 @@ class ModelSQLTranslationTestCase(unittest.TestCase):
|
||||
|
||||
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"
|
||||
|
||||
Reference in new issue
Block a user