Skip to content
Permalink
Browse files

[FIX] core: chrome doesn't abide by --http-port anymore

An http-port provided on the command line (may also have been an issue
for config files, didn't check) would not be taken in account anymore,
because `odoo.tests.common` would be imported during the import of
`odoo` itself (when loading odoo.service.server), itself importing
`odoo.tools.config` leading to a default configuration being set up.

* remove `odoo.tests.common.PORT`, `config['http_port']` should be
  used always
* defer the import of odoo.tests.common by moving it inside
  load_test_file
* stop generating default configs

closes #43135

Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
  • Loading branch information
xmo-odoo committed Jan 10, 2020
1 parent 6206e0e commit 45871f498ea4cf3ada719692e69cd413883ab442
Showing with 7 additions and 7 deletions.
  1. +3 −2 addons/website/tests/test_attachment.py
  2. +1 −1 odoo/service/server.py
  3. +3 −4 odoo/tests/common.py
@@ -1,5 +1,6 @@
import odoo.tests
from odoo.tests.common import HOST, PORT
from odoo.tests.common import HOST
from odoo.tools import config


@odoo.tests.common.tagged('post_install', '-at_install')
@@ -40,7 +41,7 @@ def test_01_type_url_301_image(self):
req = self.url_open('/web/image/test.an_image_url')
self.assertEqual(req.status_code, 200)

base = "http://%s:%s" % (HOST, PORT)
base = "http://%s:%s" % (HOST, config['http_port'])

req = self.opener.get(base + '/web/image/test.an_image_redirect_301', allow_redirects=False)
self.assertEqual(req.status_code, 301)
@@ -20,7 +20,6 @@
import psutil
import werkzeug.serving
from werkzeug.debug import DebuggedApplication
from odoo.tests.common import OdooSuite

if os.name == 'posix':
# Unix only for workers
@@ -1148,6 +1147,7 @@ def _reexec(updated_modules=None):
os.execve(sys.executable, args, os.environ)

def load_test_file_py(registry, test_file):
from odoo.tests.common import OdooSuite
threading.currentThread().testing = True
try:
test_path, _ = os.path.splitext(os.path.abspath(test_file))
@@ -69,7 +69,6 @@
# The odoo library is supposed already configured.
ADDONS_PATH = odoo.tools.config['addons_path']
HOST = '127.0.0.1'
PORT = odoo.tools.config['http_port']
# Useless constant, tests are aware of the content of demo data
ADMIN_USER_ID = odoo.SUPERUSER_ID

@@ -1048,7 +1047,7 @@ class HttpCase(TransactionCase):
def __init__(self, methodName='runTest'):
super(HttpCase, self).__init__(methodName)
# v8 api with correct xmlrpc exception handling.
self.xmlrpc_url = url_8 = 'http://%s:%d/xmlrpc/2/' % (HOST, PORT)
self.xmlrpc_url = url_8 = 'http://%s:%d/xmlrpc/2/' % (HOST, odoo.tools.config['http_port'])
self.xmlrpc_common = xmlrpclib.ServerProxy(url_8 + 'common')
self.xmlrpc_db = xmlrpclib.ServerProxy(url_8 + 'db')
self.xmlrpc_object = xmlrpclib.ServerProxy(url_8 + 'object')
@@ -1087,7 +1086,7 @@ def setUp(self):
def url_open(self, url, data=None, files=None, timeout=10, headers=None):
self.env['base'].flush()
if url.startswith('/'):
url = "http://%s:%s%s" % (HOST, PORT, url)
url = "http://%s:%s%s" % (HOST, odoo.tools.config['http_port'], url)
if data or files:
return self.opener.post(url, data=data, files=files, timeout=timeout, headers=headers)
return self.opener.get(url, timeout=timeout, headers=headers)
@@ -1166,7 +1165,7 @@ def browser_js(self, url_path, code, ready='', login=None, timeout=60, **kw):

try:
self.authenticate(login, login)
base_url = "http://%s:%s" % (HOST, PORT)
base_url = "http://%s:%s" % (HOST, odoo.tools.config['http_port'])
ICP = self.env['ir.config_parameter']
ICP.set_param('web.base.url', base_url)
# flush updates to the database before launching the client side,

0 comments on commit 45871f4

Please sign in to comment.
You can’t perform that action at this time.