def test_site_config_dirs_osx(self, monkeypatch: pytest.MonkeyPatch) -> None: monkeypatch.setenv("HOME", "/home/test") assert appdirs.site_config_dirs("pip") == [ "/Library/Application Support/pip", ]
def test_site_config_dirs_linux(self, monkeypatch): monkeypatch.setattr(_appdirs, "system", "linux2") monkeypatch.setattr(os, "path", posixpath) monkeypatch.delenv("XDG_CONFIG_DIRS", raising=False) monkeypatch.setattr(sys, "platform", "linux2") assert appdirs.site_config_dirs("pip") == ['/etc/xdg/pip', '/etc']
def test_site_config_dirs_linux_empty(self, monkeypatch): monkeypatch.setattr(_appdirs, "system", "linux2") monkeypatch.setattr(os, "path", posixpath) monkeypatch.setattr(os, "pathsep", ':') monkeypatch.setenv("XDG_CONFIG_DIRS", "") monkeypatch.setattr(sys, "platform", "linux2") assert appdirs.site_config_dirs("pip") == ['/etc/xdg/pip', '/etc']
def test_site_config_dirs_linux_empty( self, monkeypatch: pytest.MonkeyPatch) -> None: monkeypatch.setattr(os, "pathsep", ":") monkeypatch.setenv("XDG_CONFIG_DIRS", "") assert appdirs.site_config_dirs("pip") == [ "/etc/xdg/pip", "/etc", ]
def test_site_config_dirs_osx(self, monkeypatch): monkeypatch.setattr(appdirs, "WINDOWS", False) monkeypatch.setattr(os, "path", posixpath) monkeypatch.setenv("HOME", "/home/test") monkeypatch.setattr(sys, "platform", "darwin") assert appdirs.site_config_dirs("pip") == \ ["/Library/Application Support/pip"]
def test_site_config_dirs_osx(self, monkeypatch): monkeypatch.setattr(_appdirs, "system", "darwin") monkeypatch.setattr(os, "path", posixpath) monkeypatch.setenv("HOME", "/home/test") monkeypatch.setattr(sys, "platform", "darwin") assert appdirs.site_config_dirs("pip") == \ ["/Library/Application Support/pip"]
def test_site_config_dirs_linux(self, monkeypatch: pytest.MonkeyPatch) -> None: monkeypatch.delenv("XDG_CONFIG_DIRS", raising=False) assert appdirs.site_config_dirs("pip") == [ "/etc/xdg/pip", "/etc", ]
def test_site_config_dirs_linux_override(self, monkeypatch): monkeypatch.setattr(appdirs, "WINDOWS", False) monkeypatch.setattr(os, "path", posixpath) monkeypatch.setattr(os, "pathsep", ':') monkeypatch.setenv("XDG_CONFIG_DIRS", "/spam:/etc:/etc/xdg") monkeypatch.setattr(sys, "platform", "linux2") assert appdirs.site_config_dirs("pip") == [ '/spam/pip', '/etc/pip', '/etc/xdg/pip', '/etc' ]
def test_site_config_dirs_linux(self, monkeypatch): monkeypatch.setattr(appdirs, "WINDOWS", False) monkeypatch.setattr(os, "path", posixpath) monkeypatch.delenv("XDG_CONFIG_DIRS", raising=False) monkeypatch.setattr(sys, "platform", "linux2") assert appdirs.site_config_dirs("pip") == [ '/etc/xdg/pip', '/etc' ]
def test_site_config_dirs_win(self, monkeypatch: pytest.MonkeyPatch) -> None: _get_win_folder = mock.Mock(return_value="C:\\ProgramData") monkeypatch.setattr( platformdirs.windows, # type: ignore "get_win_folder", _get_win_folder, raising=False, ) assert appdirs.site_config_dirs("pip") == ["C:\\ProgramData\\pip"] assert _get_win_folder.call_args_list == [ mock.call("CSIDL_COMMON_APPDATA") ]
def get_configuration_files(): # type: () -> Dict[Kind, List[str]] global_config_files = [ os.path.join(path, CONFIG_BASENAME) for path in appdirs.site_config_dirs("pip") ] site_config_file = os.path.join(sys.prefix, CONFIG_BASENAME) legacy_config_file = os.path.join( expanduser("~"), "pip" if WINDOWS else ".pip", CONFIG_BASENAME ) new_config_file = os.path.join(appdirs.user_config_dir("pip"), CONFIG_BASENAME) return { kinds.GLOBAL: global_config_files, kinds.SITE: [site_config_file], kinds.USER: [legacy_config_file, new_config_file], }
def test_site_config_dirs_win(self, monkeypatch): @pretend.call_recorder def _get_win_folder(base): return "C:\\ProgramData" monkeypatch.setattr( appdirs, "_get_win_folder", _get_win_folder, raising=False, ) monkeypatch.setattr(appdirs, "WINDOWS", True) monkeypatch.setattr(os, "path", ntpath) assert appdirs.site_config_dirs("pip") == ["C:\\ProgramData\\pip"] assert _get_win_folder.calls == [pretend.call("CSIDL_COMMON_APPDATA")]
def test_site_config_dirs_win(self, monkeypatch): @pretend.call_recorder def _get_win_folder(base): return "C:\\ProgramData" monkeypatch.setattr( _appdirs, "_get_win_folder", _get_win_folder, raising=False, ) monkeypatch.setattr(_appdirs, "system", "win32") monkeypatch.setattr(os, "path", ntpath) assert appdirs.site_config_dirs("pip") == ["C:\\ProgramData\\pip"] assert _get_win_folder.calls == [pretend.call("CSIDL_COMMON_APPDATA")]
def get_configuration_files(): global_config_files = [ os.path.join(path, CONFIG_BASENAME) for path in appdirs.site_config_dirs('pip') ] site_config_file = os.path.join(sys.prefix, CONFIG_BASENAME) legacy_config_file = os.path.join( expanduser('~'), 'pip' if WINDOWS else '.pip', CONFIG_BASENAME, ) new_config_file = os.path.join(appdirs.user_config_dir("pip"), CONFIG_BASENAME) return { kinds.GLOBAL: global_config_files, kinds.SITE: [site_config_file], kinds.USER: [legacy_config_file, new_config_file], }
def get_configuration_files(): # type: () -> Dict[Kind, List[str]] global_config_files = [ os.path.join(path, CONFIG_BASENAME) for path in appdirs.site_config_dirs('pip') ]
legacy_config_file = os.path.join(legacy_storage_dir, config_basename,) else: bin_py = os.path.join(sys.prefix, "bin") bin_user = os.path.join(user_site, "bin") config_basename = "pip.conf" legacy_storage_dir = os.path.join(user_dir, ".pip") legacy_config_file = os.path.join(legacy_storage_dir, config_basename,) # Forcing to use /usr/local/bin for standard macOS framework installs # Also log to ~/Library/Logs/ for use with the Console.app log viewer if sys.platform[:6] == "darwin" and sys.prefix[:16] == "/System/Library/": bin_py = "/usr/local/bin" site_config_files = [ os.path.join(path, config_basename) for path in appdirs.site_config_dirs("pip") ] venv_config_file = os.path.join(sys.prefix, config_basename) new_config_file = os.path.join(appdirs.user_config_dir("pip"), config_basename) def distutils_scheme( dist_name, user=False, home=None, root=None, isolated=False, prefix=None ): """ Return a distutils install scheme """ from distutils.dist import Distribution scheme = {}
config_basename = 'pip.conf' legacy_storage_dir = os.path.join(user_dir, '.pip') legacy_config_file = os.path.join( legacy_storage_dir, config_basename, ) # Forcing to use /usr/local/bin for standard macOS framework installs # Also log to ~/Library/Logs/ for use with the Console.app log viewer if sys.platform[:6] == 'darwin' and sys.prefix[:16] == '/System/Library/': bin_py = '/usr/local/bin' global_config_files = [ os.path.join(path, config_basename) for path in appdirs.site_config_dirs('pip') ] site_config_file = os.path.join(sys.prefix, config_basename) new_config_file = os.path.join(appdirs.user_config_dir("pip"), config_basename) def distutils_scheme(dist_name, user=False, home=None, root=None, isolated=False, prefix=None): # type:(str, bool, str, str, bool, str) -> dict """ Return a distutils install scheme """ from distutils.dist import Distribution scheme = {}
else: bin_py = os.path.join(sys.prefix, "bin") bin_user = os.path.join(user_site, "bin") config_basename = "pip.conf" legacy_storage_dir = os.path.join(user_dir, ".pip") legacy_config_file = os.path.join(legacy_storage_dir, config_basename) # Forcing to use /usr/local/bin for standard macOS framework installs # Also log to ~/Library/Logs/ for use with the Console.app log viewer if sys.platform[:6] == "darwin" and sys.prefix[:16] == "/System/Library/": bin_py = "/usr/local/bin" site_config_files = [ os.path.join(path, config_basename) for path in appdirs.site_config_dirs("pip") ] venv_config_file = os.path.join(sys.prefix, config_basename) new_config_file = os.path.join(appdirs.user_config_dir("pip"), config_basename) def distutils_scheme(dist_name, user=False, home=None, root=None, isolated=False, prefix=None): """ Return a distutils install scheme """
config_basename = 'pip.conf' legacy_storage_dir = os.path.join(user_dir, '.pip') legacy_config_file = os.path.join( legacy_storage_dir, config_basename, ) # Forcing to use /usr/local/bin for standard macOS framework installs # Also log to ~/Library/Logs/ for use with the Console.app log viewer if sys.platform[:6] == 'darwin' and sys.prefix[:16] == '/System/Library/': bin_py = '/usr/local/bin' site_config_files = [ os.path.join(path, config_basename) for path in appdirs.site_config_dirs('pip') ] venv_config_file = os.path.join(sys.prefix, config_basename) new_config_file = os.path.join(appdirs.user_config_dir("pip"), config_basename) def distutils_scheme(dist_name, user=False, home=None, root=None, isolated=False, prefix=None): # type:(str, bool, str, str, bool, str) -> dict """ Return a distutils install scheme