| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 | import osimport pytestfrom compose.cli.command import get_config_path_from_optionsfrom compose.config.environment import Environmentfrom compose.const import IS_WINDOWS_PLATFORMfrom tests import mockclass TestGetConfigPathFromOptions:    def test_path_from_options(self):        paths = ['one.yml', 'two.yml']        opts = {'--file': paths}        environment = Environment.from_env_file('.')        assert get_config_path_from_options('.', opts, environment) == paths    def test_single_path_from_env(self):        with mock.patch.dict(os.environ):            os.environ['COMPOSE_FILE'] = 'one.yml'            environment = Environment.from_env_file('.')            assert get_config_path_from_options('.', {}, environment) == ['one.yml']    @pytest.mark.skipif(IS_WINDOWS_PLATFORM, reason='posix separator')    def test_multiple_path_from_env(self):        with mock.patch.dict(os.environ):            os.environ['COMPOSE_FILE'] = 'one.yml:two.yml'            environment = Environment.from_env_file('.')            assert get_config_path_from_options(                '.', {}, environment            ) == ['one.yml', 'two.yml']    @pytest.mark.skipif(not IS_WINDOWS_PLATFORM, reason='windows separator')    def test_multiple_path_from_env_windows(self):        with mock.patch.dict(os.environ):            os.environ['COMPOSE_FILE'] = 'one.yml;two.yml'            environment = Environment.from_env_file('.')            assert get_config_path_from_options(                '.', {}, environment            ) == ['one.yml', 'two.yml']    def test_multiple_path_from_env_custom_separator(self):        with mock.patch.dict(os.environ):            os.environ['COMPOSE_PATH_SEPARATOR'] = '^'            os.environ['COMPOSE_FILE'] = 'c:\\one.yml^.\\semi;colon.yml'            environment = Environment.from_env_file('.')            assert get_config_path_from_options(                '.', {}, environment            ) == ['c:\\one.yml', '.\\semi;colon.yml']    def test_no_path(self):        environment = Environment.from_env_file('.')        assert not get_config_path_from_options('.', {}, environment)    def test_unicode_path_from_options(self):        paths = [b'\xe5\xb0\xb1\xe5\x90\x83\xe9\xa5\xad/docker-compose.yml']        opts = {'--file': paths}        environment = Environment.from_env_file('.')        assert get_config_path_from_options(            '.', opts, environment        ) == ['就吃饭/docker-compose.yml']
 |