mirror of
https://github.com/odoo/runbot.git
synced 2025-03-30 23:05:44 +07:00
[FIX] runbot_merge: make local tests run in v11 as well
Runbot is supposed to run on v11, yet because the runbot_merge test suite was built on v12 due to an API change in Registry.enter_test_mode the (local) test suite would only run on v12. Add a conditional pick such that the test suite can run transparently on both v11 and v12.
This commit is contained in:
parent
6565a0f9a1
commit
e885db8a50
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
import inspect
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import werkzeug.test, werkzeug.wrappers
|
import werkzeug.test, werkzeug.wrappers
|
||||||
@ -45,15 +46,26 @@ def registry(request):
|
|||||||
yield odoo.registry(db)
|
yield odoo.registry(db)
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def env(registry):
|
def cr(registry):
|
||||||
|
# in v12, enter_test_mode flags an existing cursor while in v11 it sets one up
|
||||||
|
if inspect.signature(registry.enter_test_mode).parameters:
|
||||||
with registry.cursor() as cr:
|
with registry.cursor() as cr:
|
||||||
env = odoo.api.Environment(cr, odoo.SUPERUSER_ID, {})
|
|
||||||
ctx = env['res.users'].context_get()
|
|
||||||
registry.enter_test_mode(cr)
|
registry.enter_test_mode(cr)
|
||||||
yield env(context=ctx)
|
yield cr
|
||||||
|
registry.leave_test_mode()
|
||||||
|
cr.rollback()
|
||||||
|
else:
|
||||||
|
registry.enter_test_mode()
|
||||||
|
with registry.cursor() as cr:
|
||||||
|
yield cr
|
||||||
|
cr.rollback()
|
||||||
registry.leave_test_mode()
|
registry.leave_test_mode()
|
||||||
|
|
||||||
cr.rollback()
|
@pytest.fixture
|
||||||
|
def env(cr):
|
||||||
|
env = odoo.api.Environment(cr, odoo.SUPERUSER_ID, {})
|
||||||
|
ctx = env['res.users'].context_get()
|
||||||
|
yield env(context=ctx)
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def owner():
|
def owner():
|
||||||
|
Loading…
Reference in New Issue
Block a user