Skip to content

Commit

Permalink
Fix bug with whitespaces in config files paths
Browse files Browse the repository at this point in the history
  • Loading branch information
llacroix committed Jul 6, 2023
1 parent 7b6b05e commit 31235ac
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions odoo_tools/api/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,9 @@ def addons_paths(self):
paths = config.get('options', 'addons_path')

config_paths = set(
Path(path)
Path(path.strip())
for path in paths.split(',')
if path
if path.strip()
)

if len(config_paths) > 0 and not self.context.force_addons_lookup:
Expand Down
15 changes: 15 additions & 0 deletions tests/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,21 @@ def test_env_config_addons_path(tmp_path):
assert env.addons_paths() == set()


def test_env_config_whitespace_addons_path(tmp_path):
env = Environment()

env.context.odoo_rc = tmp_path / 'odoo.cfg'

with env.config():
env.set_config('addons_path', ",".join([f" {tmp_path}", ""]))

paths = env.addons_paths()
assert paths == {tmp_path}

env.context.force_addons_lookup = True
assert env.addons_paths() == set()


def test_invalid_env(tmp_path):
env = Environment()

Expand Down

0 comments on commit 31235ac

Please sign in to comment.