diff options
author | CoprDistGit <infra@openeuler.org> | 2023-05-05 08:48:22 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-05-05 08:48:22 +0000 |
commit | c6ad2a337c96a803285131297ee00e75b3b4bde1 (patch) | |
tree | df4002979993b33f897631da11685a06f1588b00 | |
parent | 44c8b1e31399e72c002546d62820e6453515556e (diff) |
automatic import of python-coverage-conditional-pluginopeneuler20.03
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-coverage-conditional-plugin.spec | 474 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 476 insertions, 0 deletions
@@ -0,0 +1 @@ +/coverage-conditional-plugin-0.8.0.tar.gz diff --git a/python-coverage-conditional-plugin.spec b/python-coverage-conditional-plugin.spec new file mode 100644 index 0000000..fa93a3e --- /dev/null +++ b/python-coverage-conditional-plugin.spec @@ -0,0 +1,474 @@ +%global _empty_manifest_terminate_build 0 +Name: python-coverage-conditional-plugin +Version: 0.8.0 +Release: 1 +Summary: Conditional coverage based on any rules you define! +License: MIT +URL: https://github.com/wemake-services/coverage-conditional-plugin +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/0f/ca/88445f2d1155dede7cf571a8cda6013db15f3450f05efc0a6707bf5820c6/coverage-conditional-plugin-0.8.0.tar.gz +BuildArch: noarch + +Requires: python3-coverage +Requires: python3-packaging +Requires: python3-importlib_metadata + +%description +# coverage-conditional-plugin + +[](https://wemake.services) +[](https://github.com/wemake-services/coverage-conditional-plugin/actions?query=workflow%3Atest) +[](https://codecov.io/gh/wemake-services/coverage-conditional-plugin) +[](https://pypi.org/project/coverage-conditional-plugin/) +[](https://github.com/wemake-services/wemake-python-styleguide) + +Conditional coverage based on any rules you define! + +Some projects have different parts that relies on different environments: + +- Python version, some code is only executed on specific versions and ignored on others +- OS version, some code might be Windows, Mac, or Linux only +- External packages, some code is only executed when some 3rd party package is installed + +Current best practice is to use `# pragma: no cover` for this places in our project. +This project allows to use configurable pragmas +that include code to the coverage if some condition evaluates to true, +and fallback to ignoring this code when condition is false. + +Read [the announcing post](https://sobolevn.me/2020/02/conditional-coverage). + + +## Installation + +```bash +pip install coverage-conditional-plugin +``` + +Then you will need to add to your `setup.cfg` or `.coveragerc` file +some extra configuration: + +```ini +[coverage:run] +# Here we specify plugins for coverage to be used: +plugins = + coverage_conditional_plugin + +[coverage:coverage_conditional_plugin] +# Here we specify our pragma rules: +rules = + "sys_version_info >= (3, 8)": py-gte-38 + "is_installed('mypy')": has-mypy + +``` + +Or to your `pyproject.toml`: +```toml +[tool.coverage.run] +# Here we specify plugins for coverage to be used: +plugins = ["coverage_conditional_plugin"] + +[tool.coverage.coverage_conditional_plugin.rules] +# Here we specify our pragma rules: +py-gte-38 = "sys_version_info >= (3, 8)" +has-mypy = "is_installed('mypy')" +``` + + +Adapt rules to suit your needs! + + +## Example + +Imagine that we have this code: + +```python +try: # pragma: has-django + import django +except ImportError: # pragma: has-no-django + django = None + +def run_if_django_is_installed(): + if django is not None: # pragma: has-django + ... +``` + +And here's the configuration you might use: + +```ini +[coverage:coverage_conditional_plugin] +rules = + "is_installed('django')": has-django + "not is_installed('django')": has-no-django + +``` + +When running tests with and without `django` installed +you will have `100%` coverage in both cases. + +But, different lines will be included. +With `django` installed it will include +both `try:` and `if django is not None:` conditions. + +When running without `django` installed, +it will include `except ImportError:` line. + + +## Writing pragma rules + +Format for pragma rules is: + +``` +"pragma-condition": pragma-name +``` + +Code inside `"pragma-condition"` is evaluted with `eval`. +Make sure that the input you pass there is trusted! +`"pragma-condition"` must return `bool` value after evaluation. + +We support all environment markers specified in [PEP-496](https://www.python.org/dev/peps/pep-0496/). +See [Strings](https://www.python.org/dev/peps/pep-0496/#strings) +and [Version Numbers](https://www.python.org/dev/peps/pep-0496/#version-numbers) +sections for available values. Also, we provide a bunch of additional markers: + +- `sys_version_info` is the same as [`sys.version_info`](https://docs.python.org/3/library/sys.html#sys.version_info) +- `os_environ` is the same as [`os.environ`](https://docs.python.org/3/library/os.html#os.environ) +- `is_installed` is our custom function that tries to import the passed string, returns `bool` value +- `package_version` is our custom function that tries to get package version from `pkg_resources` and returns its [parsed version](https://packaging.pypa.io/en/latest/version/#packaging.version.parse) + +Use `get_env_info` to get values for the current environment: + +```python +from coverage_conditional_plugin import get_env_info + +get_env_info() +``` + + +## License + +[MIT](https://github.com/wemake.services/coverage-conditional-plugin/blob/master/LICENSE) + + +%package -n python3-coverage-conditional-plugin +Summary: Conditional coverage based on any rules you define! +Provides: python-coverage-conditional-plugin +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-coverage-conditional-plugin +# coverage-conditional-plugin + +[](https://wemake.services) +[](https://github.com/wemake-services/coverage-conditional-plugin/actions?query=workflow%3Atest) +[](https://codecov.io/gh/wemake-services/coverage-conditional-plugin) +[](https://pypi.org/project/coverage-conditional-plugin/) +[](https://github.com/wemake-services/wemake-python-styleguide) + +Conditional coverage based on any rules you define! + +Some projects have different parts that relies on different environments: + +- Python version, some code is only executed on specific versions and ignored on others +- OS version, some code might be Windows, Mac, or Linux only +- External packages, some code is only executed when some 3rd party package is installed + +Current best practice is to use `# pragma: no cover` for this places in our project. +This project allows to use configurable pragmas +that include code to the coverage if some condition evaluates to true, +and fallback to ignoring this code when condition is false. + +Read [the announcing post](https://sobolevn.me/2020/02/conditional-coverage). + + +## Installation + +```bash +pip install coverage-conditional-plugin +``` + +Then you will need to add to your `setup.cfg` or `.coveragerc` file +some extra configuration: + +```ini +[coverage:run] +# Here we specify plugins for coverage to be used: +plugins = + coverage_conditional_plugin + +[coverage:coverage_conditional_plugin] +# Here we specify our pragma rules: +rules = + "sys_version_info >= (3, 8)": py-gte-38 + "is_installed('mypy')": has-mypy + +``` + +Or to your `pyproject.toml`: +```toml +[tool.coverage.run] +# Here we specify plugins for coverage to be used: +plugins = ["coverage_conditional_plugin"] + +[tool.coverage.coverage_conditional_plugin.rules] +# Here we specify our pragma rules: +py-gte-38 = "sys_version_info >= (3, 8)" +has-mypy = "is_installed('mypy')" +``` + + +Adapt rules to suit your needs! + + +## Example + +Imagine that we have this code: + +```python +try: # pragma: has-django + import django +except ImportError: # pragma: has-no-django + django = None + +def run_if_django_is_installed(): + if django is not None: # pragma: has-django + ... +``` + +And here's the configuration you might use: + +```ini +[coverage:coverage_conditional_plugin] +rules = + "is_installed('django')": has-django + "not is_installed('django')": has-no-django + +``` + +When running tests with and without `django` installed +you will have `100%` coverage in both cases. + +But, different lines will be included. +With `django` installed it will include +both `try:` and `if django is not None:` conditions. + +When running without `django` installed, +it will include `except ImportError:` line. + + +## Writing pragma rules + +Format for pragma rules is: + +``` +"pragma-condition": pragma-name +``` + +Code inside `"pragma-condition"` is evaluted with `eval`. +Make sure that the input you pass there is trusted! +`"pragma-condition"` must return `bool` value after evaluation. + +We support all environment markers specified in [PEP-496](https://www.python.org/dev/peps/pep-0496/). +See [Strings](https://www.python.org/dev/peps/pep-0496/#strings) +and [Version Numbers](https://www.python.org/dev/peps/pep-0496/#version-numbers) +sections for available values. Also, we provide a bunch of additional markers: + +- `sys_version_info` is the same as [`sys.version_info`](https://docs.python.org/3/library/sys.html#sys.version_info) +- `os_environ` is the same as [`os.environ`](https://docs.python.org/3/library/os.html#os.environ) +- `is_installed` is our custom function that tries to import the passed string, returns `bool` value +- `package_version` is our custom function that tries to get package version from `pkg_resources` and returns its [parsed version](https://packaging.pypa.io/en/latest/version/#packaging.version.parse) + +Use `get_env_info` to get values for the current environment: + +```python +from coverage_conditional_plugin import get_env_info + +get_env_info() +``` + + +## License + +[MIT](https://github.com/wemake.services/coverage-conditional-plugin/blob/master/LICENSE) + + +%package help +Summary: Development documents and examples for coverage-conditional-plugin +Provides: python3-coverage-conditional-plugin-doc +%description help +# coverage-conditional-plugin + +[](https://wemake.services) +[](https://github.com/wemake-services/coverage-conditional-plugin/actions?query=workflow%3Atest) +[](https://codecov.io/gh/wemake-services/coverage-conditional-plugin) +[](https://pypi.org/project/coverage-conditional-plugin/) +[](https://github.com/wemake-services/wemake-python-styleguide) + +Conditional coverage based on any rules you define! + +Some projects have different parts that relies on different environments: + +- Python version, some code is only executed on specific versions and ignored on others +- OS version, some code might be Windows, Mac, or Linux only +- External packages, some code is only executed when some 3rd party package is installed + +Current best practice is to use `# pragma: no cover` for this places in our project. +This project allows to use configurable pragmas +that include code to the coverage if some condition evaluates to true, +and fallback to ignoring this code when condition is false. + +Read [the announcing post](https://sobolevn.me/2020/02/conditional-coverage). + + +## Installation + +```bash +pip install coverage-conditional-plugin +``` + +Then you will need to add to your `setup.cfg` or `.coveragerc` file +some extra configuration: + +```ini +[coverage:run] +# Here we specify plugins for coverage to be used: +plugins = + coverage_conditional_plugin + +[coverage:coverage_conditional_plugin] +# Here we specify our pragma rules: +rules = + "sys_version_info >= (3, 8)": py-gte-38 + "is_installed('mypy')": has-mypy + +``` + +Or to your `pyproject.toml`: +```toml +[tool.coverage.run] +# Here we specify plugins for coverage to be used: +plugins = ["coverage_conditional_plugin"] + +[tool.coverage.coverage_conditional_plugin.rules] +# Here we specify our pragma rules: +py-gte-38 = "sys_version_info >= (3, 8)" +has-mypy = "is_installed('mypy')" +``` + + +Adapt rules to suit your needs! + + +## Example + +Imagine that we have this code: + +```python +try: # pragma: has-django + import django +except ImportError: # pragma: has-no-django + django = None + +def run_if_django_is_installed(): + if django is not None: # pragma: has-django + ... +``` + +And here's the configuration you might use: + +```ini +[coverage:coverage_conditional_plugin] +rules = + "is_installed('django')": has-django + "not is_installed('django')": has-no-django + +``` + +When running tests with and without `django` installed +you will have `100%` coverage in both cases. + +But, different lines will be included. +With `django` installed it will include +both `try:` and `if django is not None:` conditions. + +When running without `django` installed, +it will include `except ImportError:` line. + + +## Writing pragma rules + +Format for pragma rules is: + +``` +"pragma-condition": pragma-name +``` + +Code inside `"pragma-condition"` is evaluted with `eval`. +Make sure that the input you pass there is trusted! +`"pragma-condition"` must return `bool` value after evaluation. + +We support all environment markers specified in [PEP-496](https://www.python.org/dev/peps/pep-0496/). +See [Strings](https://www.python.org/dev/peps/pep-0496/#strings) +and [Version Numbers](https://www.python.org/dev/peps/pep-0496/#version-numbers) +sections for available values. Also, we provide a bunch of additional markers: + +- `sys_version_info` is the same as [`sys.version_info`](https://docs.python.org/3/library/sys.html#sys.version_info) +- `os_environ` is the same as [`os.environ`](https://docs.python.org/3/library/os.html#os.environ) +- `is_installed` is our custom function that tries to import the passed string, returns `bool` value +- `package_version` is our custom function that tries to get package version from `pkg_resources` and returns its [parsed version](https://packaging.pypa.io/en/latest/version/#packaging.version.parse) + +Use `get_env_info` to get values for the current environment: + +```python +from coverage_conditional_plugin import get_env_info + +get_env_info() +``` + + +## License + +[MIT](https://github.com/wemake.services/coverage-conditional-plugin/blob/master/LICENSE) + + +%prep +%autosetup -n coverage-conditional-plugin-0.8.0 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-coverage-conditional-plugin -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Fri May 05 2023 Python_Bot <Python_Bot@openeuler.org> - 0.8.0-1 +- Package Spec generated @@ -0,0 +1 @@ +970abba4dd28f507ed1372ff213270ff coverage-conditional-plugin-0.8.0.tar.gz |