Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[13.0] update upstream 483cc20b95e #4132

Merged
merged 4 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions odoo/addons/base/models/ir_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ def get_transforms(self):
('to install', 'To be installed'),
]

XML_DECLARATION = (
'<?xml version='.encode('utf-8'),
'<?xml version='.encode('utf-16-be'),
'<?xml version='.encode('utf-16-le'),
)

class Module(models.Model):
_name = "ir.module.module"
_rec_name = "shortdesc"
Expand Down Expand Up @@ -178,6 +184,11 @@ def _get_desc(self):
if path:
with tools.file_open(path, 'rb') as desc_file:
doc = desc_file.read()
if not doc.startswith(XML_DECLARATION):
try:
doc = doc.decode('utf-8')
except UnicodeDecodeError:
pass
html = lxml.html.document_fromstring(doc)
for element, attribute, link, pos in html.iterlinks():
if element.get('src') and not '//' in element.get('src') and not 'static/' in element.get('src'):
Expand Down
45 changes: 24 additions & 21 deletions odoo/modules/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,13 +467,7 @@ def get_test_modules(module, openupgrade_prefix=None):
feed unittest.TestLoader.loadTestsFromModule() """
# Try to import the module
results = _get_tests_modules('odoo.addons', module, openupgrade_prefix)

try:
importlib.import_module('odoo.upgrade.%s' % module)
except ImportError:
pass
else:
results += list(_get_upgrade_test_modules(module, openupgrade_prefix))
results += list(_get_upgrade_test_modules(module, openupgrade_prefix))

return results

Expand Down Expand Up @@ -509,20 +503,29 @@ def _get_upgrade_test_modules(module, openupgrade_prefix=None):
if openupgrade_prefix is None:
openupgrade_prefix = ''
name = openupgrade_prefix + '.tests'
upg = importlib.import_module("odoo.upgrade")
for path in map(Path, upg.__path__):
if openupgrade_prefix:
tests = (path / module / openupgrade_prefix[1:] / "tests").glob("test_*.py")
else:
tests = (path / module / "tests").glob("test_*.py")
for test in tests:
spec = importlib.util.spec_from_file_location(f"odoo.upgrade.{module}{name}.{test.stem}", test)
if not spec:
continue
pymod = importlib.util.module_from_spec(spec)
sys.modules[spec.name] = pymod
spec.loader.exec_module(pymod)
yield pymod
upgrade_modules = (
f"odoo.upgrade.{module}",
f"odoo.addons.{module}.migrations",
f"odoo.addons.{module}.upgrades",
)
for module_name in upgrade_modules:
try:
upg = importlib.import_module(module_name)
except ImportError:
continue
for path in map(Path, upg.__path__):
if openupgrade_prefix:
tests = path.glob(openupgrade_prefix[1:] + "/tests/test_*.py")
else:
tests = path.glob("tests/test_*.py")
for test in tests:
spec = importlib.util.spec_from_file_location(f"{upg.__name__}{name}.{test.stem}", test)
if not spec:
continue
pymod = importlib.util.module_from_spec(spec)
sys.modules[spec.name] = pymod
spec.loader.exec_module(pymod)
yield pymod


class OdooTestResult(unittest.result.TestResult):
Expand Down
Loading