From 3dbc304a52ca2beed5dc4e070d65bbf40e407c694125bd80313acb55997f641a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=C3=A9ta=20Machov=C3=A1?= Date: Fri, 11 Sep 2020 12:54:35 +0000 Subject: [PATCH] Accepting request 833759 from home:alarrosa:branches:devel:languages:python New package python-wheezy.template (required by hotdoc) OBS-URL: https://build.opensuse.org/request/show/833759 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-xdg?expand=0&rev=1 --- .gitattributes | 23 +++++ .gitignore | 1 + python-xdg.changes | 4 + python-xdg.spec | 61 +++++++++++++ test_xdg.py | 214 +++++++++++++++++++++++++++++++++++++++++++++ xdg-4.0.1.tar.gz | 3 + 6 files changed, 306 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 python-xdg.changes create mode 100644 python-xdg.spec create mode 100644 test_xdg.py create mode 100644 xdg-4.0.1.tar.gz diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/python-xdg.changes b/python-xdg.changes new file mode 100644 index 0000000..b21c2df --- /dev/null +++ b/python-xdg.changes @@ -0,0 +1,4 @@ +------------------------------------------------------------------- +Tue Aug 4 11:59:44 UTC 2020 - Antonio Larrosa + +- Initial release of python-xdg 4.0.1 diff --git a/python-xdg.spec b/python-xdg.spec new file mode 100644 index 0000000..c0ec0dd --- /dev/null +++ b/python-xdg.spec @@ -0,0 +1,61 @@ +# +# spec file for package python-xdg +# +# Copyright (c) 2020 SUSE LLC +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# + + +%{?!python_module:%define python_module() python-%{**} python3-%{**}} +Name: python-xdg +Version: 4.0.1 +Release: 0 +Summary: Variables defined by the XDG Base Directory Specification +License: ISC +Group: Development/Languages/Python +URL: https://github.com/srstevenson/xdg +Source: https://files.pythonhosted.org/packages/source/x/xdg/xdg-%{version}.tar.gz +Source1: https://raw.githubusercontent.com/srstevenson/xdg/master/test/test_xdg.py +BuildRequires: %{python_module pytest} +BuildRequires: %{python_module setuptools} +BuildRequires: fdupes +BuildRequires: python-rpm-macros +BuildArch: noarch +%python_subpackages + +%description +xdg is a Python module which provides the variables defined by the +XDG Base Directory Specification, to save you from duplicating the +same snippet of logic in every Python utility you write that deals +with user cache, configuration, or data files. It has no external +dependencies. + +%prep +%setup -q -n xdg-%{version} +cp %{SOURCE1} . + +%build +%python_build + +%install +%python_install +%python_expand %fdupes %{buildroot}%{$python_sitelib} + +%check +%pytest + +%files %{python_files} +%doc README.md +%{python_sitelib}/* + +%changelog diff --git a/test_xdg.py b/test_xdg.py new file mode 100644 index 0000000..ce2d563 --- /dev/null +++ b/test_xdg.py @@ -0,0 +1,214 @@ +"""Test suite for xdg.""" + +import os +import sys +from pathlib import Path +from typing import TYPE_CHECKING, Callable + +import pytest # pylint: disable=import-error + +# pylint: disable=import-error,unused-import +if TYPE_CHECKING: + from _pytest.monkeypatch import MonkeyPatch # noqa +# pylint: enable=import-error,unused-import + +HOME_DIR = Path("/homedir") + + +@pytest.fixture # type: ignore +def unimport() -> None: + """Ensure xdg is absent from sys.modules.""" + try: + del sys.modules["xdg"] + except KeyError: + pass + + +# pylint: disable=import-outside-toplevel,no-self-use,redefined-outer-name +# pylint: disable=unused-argument + + +class TestXdgCacheHome: + """Tests for XDG_CACHE_HOME.""" + + def test_unset( + self, monkeypatch: "MonkeyPatch", unimport: Callable + ) -> None: + """Test when XDG_CACHE_HOME is unset.""" + monkeypatch.delenv("XDG_CACHE_HOME", raising=False) + monkeypatch.setenv("HOME", os.fspath(HOME_DIR)) + from xdg import XDG_CACHE_HOME + + assert XDG_CACHE_HOME == HOME_DIR / ".cache" + + def test_empty( + self, monkeypatch: "MonkeyPatch", unimport: Callable + ) -> None: + """Test when XDG_CACHE_HOME is empty.""" + monkeypatch.setenv("HOME", os.fspath(HOME_DIR)) + monkeypatch.setenv("XDG_CACHE_HOME", "") + from xdg import XDG_CACHE_HOME + + assert XDG_CACHE_HOME == HOME_DIR / ".cache" + + def test_set(self, monkeypatch: "MonkeyPatch", unimport: Callable) -> None: + """Test when XDG_CACHE_HOME is set.""" + monkeypatch.setenv("XDG_CACHE_HOME", "/xdg_cache_home") + from xdg import XDG_CACHE_HOME + + assert XDG_CACHE_HOME == Path("/xdg_cache_home") + + +class TestXdgConfigDirs: + """Tests for XDG_CONFIG_DIRS.""" + + def test_unset( + self, monkeypatch: "MonkeyPatch", unimport: Callable + ) -> None: + """Test when XDG_CONFIG_DIRS is unset.""" + monkeypatch.delenv("XDG_CONFIG_DIRS", raising=False) + from xdg import XDG_CONFIG_DIRS + + assert XDG_CONFIG_DIRS == [Path("/etc/xdg")] + + def test_empty( + self, monkeypatch: "MonkeyPatch", unimport: Callable + ) -> None: + """Test when XDG_CONFIG_DIRS is empty.""" + monkeypatch.setenv("XDG_CONFIG_DIRS", "") + from xdg import XDG_CONFIG_DIRS + + assert XDG_CONFIG_DIRS == [Path("/etc/xdg")] + + def test_set(self, monkeypatch: "MonkeyPatch", unimport: Callable) -> None: + """Test when XDG_CONFIG_DIRS is set.""" + monkeypatch.setenv("XDG_CONFIG_DIRS", "/first:/sec/ond") + from xdg import XDG_CONFIG_DIRS + + assert XDG_CONFIG_DIRS == [Path("/first"), Path("/sec/ond")] + + +class TestXdgConfigHome: + """Tests for XDG_CONFIG_HOME.""" + + def test_unset( + self, monkeypatch: "MonkeyPatch", unimport: Callable + ) -> None: + """Test when XDG_CONFIG_HOME is unset.""" + monkeypatch.delenv("XDG_CONFIG_HOME", raising=False) + monkeypatch.setenv("HOME", os.fspath(HOME_DIR)) + from xdg import XDG_CONFIG_HOME + + assert XDG_CONFIG_HOME == HOME_DIR / ".config" + + def test_empty( + self, monkeypatch: "MonkeyPatch", unimport: Callable + ) -> None: + """Test when XDG_CONFIG_HOME is empty.""" + monkeypatch.setenv("HOME", os.fspath(HOME_DIR)) + monkeypatch.setenv("XDG_CONFIG_HOME", "") + from xdg import XDG_CONFIG_HOME + + assert XDG_CONFIG_HOME == HOME_DIR / ".config" + + def test_set(self, monkeypatch: "MonkeyPatch", unimport: Callable) -> None: + """Test when XDG_CONFIG_HOME is set.""" + monkeypatch.setenv("XDG_CONFIG_HOME", "/xdg_config_home") + from xdg import XDG_CONFIG_HOME + + assert XDG_CONFIG_HOME == Path("/xdg_config_home") + + +class TestXdgDataDirs: + """Tests for XDG_DATA_DIRS.""" + + def test_unset( + self, monkeypatch: "MonkeyPatch", unimport: Callable + ) -> None: + """Test when XDG_DATA_DIRS is unset.""" + monkeypatch.delenv("XDG_DATA_DIRS", raising=False) + from xdg import XDG_DATA_DIRS + + assert XDG_DATA_DIRS == [ + Path("/usr/local/share/"), + Path("/usr/share/"), + ] + + def test_empty( + self, monkeypatch: "MonkeyPatch", unimport: Callable + ) -> None: + """Test when XDG_DATA_DIRS is empty.""" + monkeypatch.setenv("XDG_DATA_DIRS", "") + from xdg import XDG_DATA_DIRS + + assert XDG_DATA_DIRS == [ + Path("/usr/local/share/"), + Path("/usr/share/"), + ] + + def test_set(self, monkeypatch: "MonkeyPatch", unimport: Callable) -> None: + """Test when XDG_DATA_DIRS is set.""" + monkeypatch.setenv("XDG_DATA_DIRS", "/first/:/sec/ond/") + from xdg import XDG_DATA_DIRS + + assert XDG_DATA_DIRS == [Path("/first/"), Path("/sec/ond/")] + + +class TestXdgDataHome: + """Tests for XDG_DATA_HOME.""" + + def test_unset( + self, monkeypatch: "MonkeyPatch", unimport: Callable + ) -> None: + """Test when XDG_DATA_HOME is unset.""" + monkeypatch.delenv("XDG_DATA_HOME", raising=False) + monkeypatch.setenv("HOME", os.fspath(HOME_DIR)) + from xdg import XDG_DATA_HOME + + assert XDG_DATA_HOME == HOME_DIR / ".local" / "share" + + def test_empty( + self, monkeypatch: "MonkeyPatch", unimport: Callable + ) -> None: + """Test when XDG_DATA_HOME is empty.""" + monkeypatch.setenv("HOME", os.fspath(HOME_DIR)) + monkeypatch.setenv("XDG_DATA_HOME", "") + from xdg import XDG_DATA_HOME + + assert XDG_DATA_HOME == HOME_DIR / ".local" / "share" + + def test_set(self, monkeypatch: "MonkeyPatch", unimport: Callable) -> None: + """Test when XDG_DATA_HOME is set.""" + monkeypatch.setenv("XDG_DATA_HOME", "/xdg_data_home") + from xdg import XDG_DATA_HOME + + assert XDG_DATA_HOME == Path("/xdg_data_home") + + +class TestXdgRuntimeDir: + """Tests for XDG_RUNTIME_DIR.""" + + def test_unset( + self, monkeypatch: "MonkeyPatch", unimport: Callable + ) -> None: + """Test when XDG_RUNTIME_DIR is unset.""" + monkeypatch.delenv("XDG_RUNTIME_DIR", raising=False) + from xdg import XDG_RUNTIME_DIR + + assert XDG_RUNTIME_DIR is None + + def test_empty( + self, monkeypatch: "MonkeyPatch", unimport: Callable + ) -> None: + """Test when XDG_RUNTIME_DIR is empty.""" + monkeypatch.setenv("XDG_RUNTIME_DIR", "") + from xdg import XDG_RUNTIME_DIR + + assert XDG_RUNTIME_DIR == Path("") + + def test_set(self, monkeypatch: "MonkeyPatch", unimport: Callable) -> None: + """Test when XDG_RUNTIME_DIR is set.""" + monkeypatch.setenv("XDG_RUNTIME_DIR", "/xdg_runtime_dir") + from xdg import XDG_RUNTIME_DIR + + assert XDG_RUNTIME_DIR == Path("/xdg_runtime_dir") diff --git a/xdg-4.0.1.tar.gz b/xdg-4.0.1.tar.gz new file mode 100644 index 0000000..7ff5224 --- /dev/null +++ b/xdg-4.0.1.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c939c99def394cbaf765a3ee55efd6ea7e4c5eaed8d9ebc2d03af84ba35dec57 +size 3817