Skip to content

Commit b7660bd

Browse files
committed
[FIX] tests/test_util: use new cursor for commit in tests
Since odoo/odoo@1241fac8 we can not longer commit test cursors. Some tests here actually test flows using `commit`. To avoid the issue we use an extra cursor. closes #117 Signed-off-by: Christophe Simonis (chs) <[email protected]>
1 parent 1b93d0d commit b7660bd

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/base/tests/test_util.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -652,8 +652,13 @@ def test_pg_text2html(self, value, expected):
652652
result = cr.fetchone()[0]
653653
self.assertEqual(result, expected)
654654

655+
def _get_cr(self):
656+
cr = self.registry.cursor()
657+
self.addCleanup(cr.close)
658+
return cr
659+
655660
def test_explode_mult_filters(self):
656-
cr = self.env.cr
661+
cr = self._get_cr()
657662
queries = util.explode_query_range(
658663
cr,
659664
"""
@@ -704,7 +709,7 @@ def test_explode_query_range(self):
704709
self.assertEqual(len(qs), 1) # 10% rule for second bucket, 1 <= 0.1(count - 1) since count >= 11
705710

706711
def test_parallel_rowcount(self):
707-
cr = self.env.cr
712+
cr = self._get_cr()
708713
cr.execute("SELECT count(*) FROM res_lang")
709714
[expected] = cr.fetchone()
710715

@@ -724,7 +729,7 @@ def test_parallel_execute_retry_on_serialization_failure(self):
724729
TEST_TABLE_NAME = "_upgrade_serialization_failure_test_table"
725730
N_ROWS = 10
726731

727-
cr = self.env.cr
732+
cr = self._get_cr()
728733

729734
cr.execute(
730735
util.format_query(

0 commit comments

Comments
 (0)