From 354d171eb8654de7334a19072bd80347b8885ba7 Mon Sep 17 00:00:00 2001 From: "daniel.asztalos" Date: Fri, 29 Mar 2019 10:16:01 +0100 Subject: [PATCH] Fix path list with whitespace --- src/rez/config.py | 4 ++++ src/rez/tests/test_config.py | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/rez/config.py b/src/rez/config.py index f0f096175f..f7449c072a 100644 --- a/src/rez/config.py +++ b/src/rez/config.py @@ -126,6 +126,10 @@ class OptionalStrList(StrList): class PathList(StrList): sep = os.pathsep + def _parse_env_var(self, value): + value = value.split(self.sep) + return [x for x in value if x] + class Int(Setting): schema = Schema(int) diff --git a/src/rez/tests/test_config.py b/src/rez/tests/test_config.py index 37f0e8ff63..0c649042a3 100644 --- a/src/rez/tests/test_config.py +++ b/src/rez/tests/test_config.py @@ -226,6 +226,19 @@ def _data(self): finally: os.environ = old_environ + def test_7(self): + """Test path list environment variable with whitespace.""" + c = Config([self.root_config_file], locked=False) + + # test basic env-var override + packages_path = [ + "c:/foo bar/baz", + "c:/foo 2 bar/baz", + ] + os.environ["REZ_PACKAGES_PATH"] = os.pathsep.join(packages_path) + + self.assertEqual(c.packages_path, packages_path) + if __name__ == '__main__': unittest.main()