コード例 #1
0
    def test_user_config_dir_osx(self, monkeypatch):
        monkeypatch.setattr(appdirs, "WINDOWS", False)
        monkeypatch.setattr(os, "path", posixpath)
        monkeypatch.setenv("HOME", "/home/test")
        monkeypatch.setattr(sys, "platform", "darwin")

        if os.path.isdir('/home/test/Library/Application Support/'):
            assert (appdirs.user_data_dir("pip") ==
                    "/home/test/Library/Application Support/pip")
        else:
            assert (appdirs.user_data_dir("pip") == "/home/test/.config/pip")
コード例 #2
0
ファイル: test_appdirs.py プロジェクト: mwilliamson/pip
    def test_user_config_dir_osx(self, monkeypatch):
        monkeypatch.setattr(appdirs, "WINDOWS", False)
        monkeypatch.setattr(os, "path", posixpath)
        monkeypatch.setenv("HOME", "/home/test")
        monkeypatch.setattr(sys, "platform", "darwin")

        if os.path.isdir('/home/test/Library/Application Support/'):
                assert (appdirs.user_data_dir("pip") ==
                        "/home/test/Library/Application Support/pip")
        else:
                assert (appdirs.user_data_dir("pip") ==
                        "/home/test/.config/pip")
コード例 #3
0
    def test_user_data_dir_linux_override(self, monkeypatch):
        monkeypatch.setattr(appdirs, "WINDOWS", False)
        monkeypatch.setattr(os, "path", posixpath)
        monkeypatch.setenv("XDG_DATA_HOME", "/home/test/.other-share")
        monkeypatch.setenv("HOME", "/home/test")
        monkeypatch.setattr(sys, "platform", "linux2")

        assert appdirs.user_data_dir("pip") == "/home/test/.other-share/pip"
コード例 #4
0
ファイル: test_appdirs.py プロジェクト: benesch/pip
    def test_user_data_dir_linux_override(self, monkeypatch):
        monkeypatch.setattr(appdirs, "WINDOWS", False)
        monkeypatch.setattr(os, "path", posixpath)
        monkeypatch.setenv("XDG_DATA_HOME", "/home/test/.other-share")
        monkeypatch.setenv("HOME", "/home/test")
        monkeypatch.setattr(sys, "platform", "linux2")

        assert appdirs.user_data_dir("pip") == "/home/test/.other-share/pip"
コード例 #5
0
    def test_user_data_dir_linux_home_slash(self, monkeypatch):
        monkeypatch.setattr(appdirs, "WINDOWS", False)
        monkeypatch.setattr(os, "path", posixpath)
        # Verify that we are not affected by http://bugs.python.org/issue14768
        monkeypatch.delenv("XDG_DATA_HOME")
        monkeypatch.setenv("HOME", "/")
        monkeypatch.setattr(sys, "platform", "linux2")

        assert appdirs.user_data_dir("pip") == "/.local/share/pip"
コード例 #6
0
ファイル: test_appdirs.py プロジェクト: benesch/pip
    def test_user_data_dir_linux_home_slash(self, monkeypatch):
        monkeypatch.setattr(appdirs, "WINDOWS", False)
        monkeypatch.setattr(os, "path", posixpath)
        # Verify that we are not affected by http://bugs.python.org/issue14768
        monkeypatch.delenv("XDG_DATA_HOME")
        monkeypatch.setenv("HOME", "/")
        monkeypatch.setattr(sys, "platform", "linux2")

        assert appdirs.user_data_dir("pip") == "/.local/share/pip"
コード例 #7
0
ファイル: test_appdirs.py プロジェクト: zdexter/docker
    def test_user_data_dir_win_no_roaming(self, monkeypatch):
        @pretend.call_recorder
        def _get_win_folder(base):
            return "C:\\Users\\test\\AppData\\Local"

        monkeypatch.setattr(
            appdirs,
            "_get_win_folder",
            _get_win_folder,
            raising=False,
        )
        monkeypatch.setattr(appdirs, "WINDOWS", True)

        assert (appdirs.user_data_dir("pip").replace(
            "/", "\\") == "C:\\Users\\test\\AppData\\Local\\pip")
        assert _get_win_folder.calls == [pretend.call("CSIDL_LOCAL_APPDATA")]
コード例 #8
0
ファイル: test_appdirs.py プロジェクト: Yasumoto/pip
    def test_user_data_dir_win_no_roaming(self, monkeypatch):
        @pretend.call_recorder
        def _get_win_folder(base):
            return "C:\\Users\\test\\AppData\\Local"

        monkeypatch.setattr(
            appdirs,
            "_get_win_folder",
            _get_win_folder,
            raising=False,
        )
        monkeypatch.setattr(appdirs, "WINDOWS", True)

        assert (appdirs.user_data_dir("pip").replace("/", "\\")
                == "C:\\Users\\test\\AppData\\Local\\pip")
        assert _get_win_folder.calls == [pretend.call("CSIDL_LOCAL_APPDATA")]
コード例 #9
0
    def test_user_data_dir_win_yes_roaming(self, monkeypatch):
        @pretend.call_recorder
        def _get_win_folder(base):
            return "C:\\Users\\test\\AppData\\Roaming"

        monkeypatch.setattr(
            appdirs,
            "_get_win_folder",
            _get_win_folder,
            raising=False,
        )
        monkeypatch.setattr(appdirs, "WINDOWS", True)
        monkeypatch.setattr(os, "path", ntpath)

        assert (appdirs.user_data_dir(
            "pip", roaming=True) == "C:\\Users\\test\\AppData\\Roaming\\pip")
        assert _get_win_folder.calls == [pretend.call("CSIDL_APPDATA")]
コード例 #10
0
ファイル: test_appdirs.py プロジェクト: benesch/pip
    def test_user_data_dir_win_yes_roaming(self, monkeypatch):
        @pretend.call_recorder
        def _get_win_folder(base):
            return "C:\\Users\\test\\AppData\\Roaming"

        monkeypatch.setattr(
            appdirs,
            "_get_win_folder",
            _get_win_folder,
            raising=False,
        )
        monkeypatch.setattr(appdirs, "WINDOWS", True)
        monkeypatch.setattr(os, "path", ntpath)

        assert (
            appdirs.user_data_dir("pip", roaming=True) ==
            "C:\\Users\\test\\AppData\\Roaming\\pip"
        )
        assert _get_win_folder.calls == [pretend.call("CSIDL_APPDATA")]
コード例 #11
0
ファイル: test_appdirs.py プロジェクト: zdexter/docker
    def test_user_data_dir_linux(self, monkeypatch):
        monkeypatch.delenv("XDG_DATA_HOME")
        monkeypatch.setenv("HOME", "/home/test")
        monkeypatch.setattr(sys, "platform", "linux2")

        assert appdirs.user_data_dir("pip") == "/home/test/.local/share/pip"
コード例 #12
0
ファイル: test_appdirs.py プロジェクト: zdexter/docker
    def test_user_data_dir_osx(self, monkeypatch):
        monkeypatch.setenv("HOME", "/home/test")
        monkeypatch.setattr(sys, "platform", "darwin")

        assert (appdirs.user_data_dir("pip") ==
                "/home/test/Library/Application Support/pip")
コード例 #13
0
def data_dir() -> str:
    directory = appdirs.user_data_dir(APPNAME, APPAUTHOR)
    if not os.path.exists(directory):
        os.makedirs(directory)
    return directory
コード例 #14
0
ファイル: test_appdirs.py プロジェクト: Yasumoto/pip
    def test_user_data_dir_linux(self, monkeypatch):
        monkeypatch.delenv("XDG_DATA_HOME")
        monkeypatch.setenv("HOME", "/home/test")
        monkeypatch.setattr(sys, "platform", "linux2")

        assert appdirs.user_data_dir("pip") == "/home/test/.local/share/pip"
コード例 #15
0
ファイル: test_appdirs.py プロジェクト: Yasumoto/pip
    def test_user_data_dir_osx(self, monkeypatch):
        monkeypatch.setenv("HOME", "/home/test")
        monkeypatch.setattr(sys, "platform", "darwin")

        assert (appdirs.user_data_dir("pip")
                == "/home/test/Library/Application Support/pip")