diff --git a/trytond/trytond/tests/test_res.py b/trytond/trytond/tests/test_res.py index 940bf003cb..266129bcdc 100644 --- a/trytond/trytond/tests/test_res.py +++ b/trytond/trytond/tests/test_res.py @@ -17,6 +17,13 @@ class ResTestCase(ModuleTestCase): 'Test res module' module = 'res' + @with_transaction() + def tearDown(self): + pool = Pool() + Warning_ = pool.get('res.user.warning') + Warning_.delete(Warning_.search([])) + Transaction().commit() + @unittest.skipUnless(PIL, "Avatars are not generated without PIL") @with_transaction() def test_user_avatar(self): @@ -44,14 +51,12 @@ class ResTestCase(ModuleTestCase): pool = Pool() Warning_ = pool.get('res.user.warning') - user_id = Transaction().user - Warning_.create([{ - 'user': user_id, - 'name': 'test', - }]) + with Transaction().new_transaction(): + Warning_.skip('test') + self.assertFalse(Warning_.check('test')) - self.assertFalse(Warning_.check('test')) - self.assertFalse(Warning_.search([])) + with Transaction().new_transaction(): + self.assertTrue(Warning_.check('test')) @with_transaction() def test_user_warning_always_ignored(self): @@ -59,15 +64,12 @@ class ResTestCase(ModuleTestCase): pool = Pool() Warning_ = pool.get('res.user.warning') - user_id = Transaction().user - Warning_.create([{ - 'user': user_id, - 'name': 'test', - 'always': True, - }]) + with Transaction().new_transaction(): + Warning_.skip('test', always=True) + self.assertFalse(Warning_.check('test')) - self.assertFalse(Warning_.check('test')) - self.assertTrue(Warning_.search([])) + with Transaction().new_transaction(): + self.assertFalse(Warning_.check('test')) @with_transaction() def test_user_warning_reentrant(self): @@ -75,11 +77,7 @@ class ResTestCase(ModuleTestCase): pool = Pool() Warning_ = pool.get('res.user.warning') - user_id = Transaction().user - Warning_.create([{ - 'user': user_id, - 'name': 'test', - }]) + Warning_.skip('test') self.assertFalse(Warning_.check('test')) self.assertFalse(Warning_.check('test'))