Skip to content
Browse files

[IMP] test_lint: add a test to detect git conflict markers

Since the deployement of the forward-port bot, chances to merge code
with conflict markers has greatly increased.

With this commit, a new test is added to grep for those markers in most
common code files.

closes #39983

X-original-commit: 80f22f9
Signed-off-by: Christophe Monniez (moc) <>
  • Loading branch information...
d-fence authored and fw-bot committed Nov 5, 2019
1 parent 4b612e1 commit 32f30e0ec2f94855c0041d8db743d09e890c5e17
Showing with 39 additions and 0 deletions.
  1. +1 −0 odoo/addons/test_lint/tests/
  2. +38 −0 odoo/addons/test_lint/tests/
@@ -1,2 +1,3 @@
from . import test_pylint
from . import test_ecmascript
from . import test_markers
@@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

import logging
import os
import odoo
from odoo.tests.common import TransactionCase
from odoo.modules.module import ad_paths

_logger = logging.getLogger(__name__)
MARKERS = [b'<' * 7, b'>' * 7]
EXTENSIONS = ('.py', '.js', '.xml', '.less', '.sass')

class TestConflictMarkers(TransactionCase):

def check_file(self, fullpath_name):

with open(fullpath_name, 'rb') as f:
content =
self.assertFalse(any([m in content for m in MARKERS]), 'Conflict markers found in %s' % fullpath_name)

def test_conflict_markers(self):
""" Test that there are no conflict markers left in Odoo files """

counter = 0

odoo_path = os.path.dirname(odoo.__file__)
paths = ad_paths + [odoo_path]
paths.remove(os.path.join(odoo_path, 'addons')) # avoid checking odoo/addons twice

for p in paths:
for dp, _, file_names in os.walk(p):
for fn in file_names:
if fn.endswith(EXTENSIONS):
self.check_file(os.path.join(dp, fn))
counter += 1'%s files tested', counter)

0 comments on commit 32f30e0

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