From 6046bca8e2f87d990030dabd338cc0531b5afff2 Mon Sep 17 00:00:00 2001 From: bitranox Date: Sat, 8 Aug 2020 14:28:13 +0200 Subject: [PATCH] refractor --- .docs/README_template.rst | 2 +- .docs/installation.rst | 17 +--- .docs/installation_via_pypi.rst | 4 - .docs/tested_under.rst | 2 +- .travis.yml | 75 +++++++++------- CHANGES.rst | 8 ++ README.rst | 32 +++---- conftest.py | 15 +--- lib_platform/__init__conf__.py | 4 +- mypy.ini | 7 -- pyproject.toml | 7 ++ pytest.ini | 18 ---- requirements_test.txt | 13 +-- setup.cfg | 23 +++-- setup.py | 86 +++++++++++-------- tests/local_testscripts/lib_bash_functions.sh | 36 +++++--- tests/local_testscripts/run_pytest.sh | 13 ++- tests/local_testscripts/run_testloop.sh | 29 ++++--- tests/test_cli.py | 4 +- tests/test_lib_platform.py | 2 +- 20 files changed, 210 insertions(+), 187 deletions(-) delete mode 100644 mypy.ini create mode 100644 pyproject.toml delete mode 100644 pytest.ini diff --git a/.docs/README_template.rst b/.docs/README_template.rst index 8cc2e22..8c5edfd 100644 --- a/.docs/README_template.rst +++ b/.docs/README_template.rst @@ -2,7 +2,7 @@ lib_platform ============ -Version v1.2.5 as of 2020-08-01 see `Changelog`_ +Version v1.2.6 as of 2020-08-08 see `Changelog`_ .. include:: ./badges.rst diff --git a/.docs/installation.rst b/.docs/installation.rst index 8a64fdc..4d56e45 100644 --- a/.docs/installation.rst +++ b/.docs/installation.rst @@ -5,24 +5,17 @@ python -m pip --upgrade pip python -m pip --upgrade setuptools - python -m pip --upgrade wheel + .. include:: ./installation_via_pypi.rst -- to install the latest development version from github via pip: +- to install the latest version from github via pip: .. code-block:: bash - # normal install python -m pip install --upgrade git+https://github.com/bitranox/lib_platform.git - # to test without installing (can be skipped) - python -m pip install git+https://github.com/bitranox/lib_platform.git --install-option test - - # to install and upgrade all dependencies regardless of version number - python -m pip install --upgrade git+https://github.com/bitranox/lib_platform.git --upgrade-strategy eager - - include it into Your requirements.txt: @@ -39,7 +32,6 @@ python -m pip install --upgrade -r //requirements.txt - - to install the latest development version from source code: .. code-block:: bash @@ -47,11 +39,6 @@ # cd ~ $ git clone https://github.com/bitranox/lib_platform.git $ cd lib_platform - - # to test without installing (can be skipped) - python setup.py test - - # normal install python setup.py install diff --git a/.docs/installation_via_pypi.rst b/.docs/installation_via_pypi.rst index 46c7cd0..fc4fa39 100644 --- a/.docs/installation_via_pypi.rst +++ b/.docs/installation_via_pypi.rst @@ -2,8 +2,4 @@ .. code-block:: bash - # install latest release from PyPi python -m pip install --upgrade lib_platform - - # test latest release from PyPi without installing (can be skipped) - python -m pip install lib_platform --install-option test diff --git a/.docs/tested_under.rst b/.docs/tested_under.rst index 6fb0643..bc6d845 100644 --- a/.docs/tested_under.rst +++ b/.docs/tested_under.rst @@ -1,3 +1,3 @@ tested on linux "bionic" with python 3.6, 3.7, 3.8, 3.8-dev, pypy3 - architectures: amd64, ppc64le, s390x, arm64 -`100% code coverage `_, codestyle checking ,mypy static type checking ,tested under `Linux, macOS, Windows `_, automatic daily builds and monitoring +`100% code coverage `_, flake8 style checking ,mypy static type checking ,tested under `Linux, macOS, Windows `_, automatic daily builds and monitoring diff --git a/.travis.yml b/.travis.yml index e760822..e539ea8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,8 +13,23 @@ env: - cPIP="python -m pip" # switch off wine fix me messages - WINEDEBUG=fixme-all - # mypy path + + # PYTEST + - PYTEST_DO_TESTS="True" + + # FLAKE8 tests + - DO_FLAKE8_TESTS="True" + + # MYPY tests + - MYPY_DO_TESTS="True" + - MYPY_OPTIONS="--follow-imports=normal --implicit-reexport --no-warn-unused-ignores --strict" - MYPYPATH="./lib_platform/3rd_party_stubs" + + # coverage + - DO_COVERAGE="True" + - DO_COVERAGE_UPLOAD_CODECOV="True" + - DO_COVERAGE_UPLOAD_CODE_CLIMATE="True" + # package name - PACKAGE_NAME="lib_platform" # the registered CLI Command @@ -23,11 +38,13 @@ env: - RST_INCLUDE_SOURCE="./.docs/README_template.rst" # the target file for rst_include (rebuild rst file includes) - RST_INCLUDE_TARGET="./README.rst" + # secure environment variable - secure: "IDAldo6HWLAFHnQg4SRyMO4og923nEjeQ/jeOeFUhvgb8/p8Sq01NZR+CH6EC/YRucTjbuBwociJXgQ88hkYprczbWGiijU0MgV/iiRPHd0/f8ZLOTXsOKK81pKV1wcrZMOsqRwwXCjRZHRr2dwK7kJKlV/5p/ESFI9ZscMZrOllS/vEwoPkyWo8rkMjV/oVvC9N8LENvCDjVseODYBXKMpN9TmrICIghiqnndNU0zdOUmNUqquQajxWRiCfowktkmPBkZpJvCDRm6TEgckVHdnczZE4Hzm8SIqEnQK/FAvy+9N65dbH7yiKufTBBdsQrwtwH1+CAAlIbeWnGtezOSON9zRkJYAjeeE1/ax28coh0NiIg0hNCzSawEjp0mVJnvwYDpW06szvBURaOYtCz9FZ8//Ql5xIKCM9IxX3FMiwhoEKHsmbkYEc5KmljkBBNaKOoxI8rFN26XvqoI9y2aRR7I/fFWxfFiIgVsRo1CL1qFhl+R0dnHbNK0abcGLQ6mRmvqXvQb3tW67So13NBueLfBibARR6uE7lh27JG0rLa92Xez2TPBr0mUOS4QDyrNNXv94LHUzO6rrSO3ZCXqXadqX340EcB9J8TG7a6jLp6R03uLCeGCda7ZWpF/9jbD4iAsDExCb+twwfaN0FCKxYn0VTDFLcJRHv2l4wIGM=" # CC_TEST_REPORTER_ID.secret - secure: "wK8WmNhbVEkbI8V3vSGKFtme/75tL/DItotP66lUleD0sgQyNs3EM+USZPtkFkpJYnIyaX+qfH1zMR+nwLcOmbWHFAcyRBJXmDDDU3E3+UGEJ8DcLEktYOvnY5fGPdbjN5OMDbNdDYwwkC1Ggq/Cqbt1IwYNBCiuzxVtKIPo7oPFShg1mzkvmRTWD4MGygOUYlNTx9/x8OrnXrbj15tGRbrgjF3QE1HC87E464DUN77RZkNmV4ObW/sjo0LqubYeo5Je32oYk7Ys1akFQnPNxYgk+sFA2EvlvLdqDwK/GrV8KTB2OmhA0pgEFR505pCvHiPIA6WbShj2fffqNXUfFHHULo/sgHxI59Fk+lM5jjBQ+OiQuS41BoNhs02pLeuHsNBwRcqFu9MTrDKOtyIuMfbjG4MUTf6x6yleDRkGIkxZLQ0X6QDLOikEb0bVVxZ/xC3lrNfpgz6kRlXfopsBZK1AVrA3HnvhAeI+WjgsYxnHnLLuFddmKn6JpUaYn6GsS+k8gml0t82hi5d77dzVjycgdihk0nEwxbXLpSNuOSEIQu+TXnQZwpV8GOsnpHNYdvfAZIyQ7NZNQqO3O1hrA3qy3bbK87ZgwtkOg4/iZdVjBzEDHF6x2Hw/275WY/b9E3VL1yW+p5w1txG3tPb+wy7kVHmuW3SdmbP12y+a8aE=" # PYPI_PASSWORD.secret + addons: apt: packages: @@ -59,7 +76,7 @@ matrix: - export DEPLOY_SDIST="False" - export DEPLOY_WHEEL="False" - export DEPLOY_TEST="False" - - export MYPY_STRICT="True" + - export MYPY_DO_TESTS="True" - os: linux @@ -69,10 +86,10 @@ matrix: python: "3.6" before_install: - export BUILD_DOCS="False" - - export DEPLOY_SDIST="False" - - export DEPLOY_WHEEL="False" - - export DEPLOY_TEST="True" - - export MYPY_STRICT="True" + - export DEPLOY_SDIST="True" + - export DEPLOY_WHEEL="True" + - export BUILD_TEST="True" + - export MYPY_DO_TESTS="True" - os: linux arch: "amd64" @@ -81,10 +98,10 @@ matrix: python: "3.7" before_install: - export BUILD_DOCS="False" - - export DEPLOY_SDIST="False" + - export DEPLOY_SDIST="True" - export DEPLOY_WHEEL="False" - - export DEPLOY_TEST="True" - - export MYPY_STRICT="True" + - export BUILD_TEST="True" + - export MYPY_DO_TESTS="True" - os: linux arch: "amd64" @@ -95,8 +112,8 @@ matrix: - export BUILD_DOCS="True" - export DEPLOY_SDIST="True" - export DEPLOY_WHEEL="True" - - export DEPLOY_TEST="True" - - export MYPY_STRICT="True" + - export BUILD_TEST="True" + - export MYPY_DO_TESTS="True" - os: linux arch: "amd64" @@ -105,10 +122,10 @@ matrix: python: "3.8-dev" before_install: - export BUILD_DOCS="False" - - export DEPLOY_SDIST="False" - - export DEPLOY_WHEEL="False" - - export DEPLOY_TEST="True" - - export MYPY_STRICT="True" + - export DEPLOY_SDIST="True" + - export DEPLOY_WHEEL="True" + - export BUILD_TEST="True" + - export MYPY_DO_TESTS="True" - os: linux arch: "amd64" @@ -117,10 +134,10 @@ matrix: python: "pypy3" before_install: - export BUILD_DOCS="False" - - export DEPLOY_SDIST="False" - - export DEPLOY_WHEEL="False" - - export DEPLOY_TEST="True" - - export MYPY_STRICT="False" + - export DEPLOY_SDIST="True" + - export DEPLOY_WHEEL="True" + - export BUILD_TEST="True" + - export MYPY_DO_TESTS="False" - os: linux arch: "ppc64le" @@ -129,10 +146,10 @@ matrix: python: "3.8" before_install: - export BUILD_DOCS="False" - - export DEPLOY_SDIST="False" + - export DEPLOY_SDIST="True" - export DEPLOY_WHEEL="True" - - export DEPLOY_TEST="True" - - export MYPY_STRICT="True" + - export BUILD_TEST="True" + - export MYPY_DO_TESTS="True" - os: linux arch: "s390x" @@ -141,10 +158,10 @@ matrix: python: "3.8" before_install: - export BUILD_DOCS="False" - - export DEPLOY_SDIST="False" + - export DEPLOY_SDIST="True" - export DEPLOY_WHEEL="True" - - export DEPLOY_TEST="True" - - export MYPY_STRICT="True" + - export BUILD_TEST="True" + - export MYPY_DO_TESTS="True" - os: linux arch: "arm64" @@ -153,10 +170,10 @@ matrix: python: "3.8" before_install: - export BUILD_DOCS="False" - - export DEPLOY_SDIST="False" + - export DEPLOY_SDIST="True" - export DEPLOY_WHEEL="True" - - export DEPLOY_TEST="True" - - export MYPY_STRICT="True" + - export BUILD_TEST="True" + - export MYPY_DO_TESTS="True" - os: osx if: true @@ -173,7 +190,7 @@ matrix: - export DEPLOY_SDIST="False" - export DEPLOY_WHEEL="False" - export DEPLOY_TEST="True" - - export MYPY_STRICT="True" + - export MYPY_DO_TESTS="True" install: diff --git a/CHANGES.rst b/CHANGES.rst index 3af442d..58889a3 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,14 @@ Changelog - new MINOR version for added functionality in a backwards compatible manner - new PATCH version for backwards compatible bug fixes +v1.2.6 +-------- +2020-08-08: service release + - fix documentation + - fix travis + - deprecate pycodestyle + - implement flake8 + v1.2.5 --------- 2020-08-01: fix pypi deploy diff --git a/README.rst b/README.rst index 68ddb64..bf00c7d 100644 --- a/README.rst +++ b/README.rst @@ -2,7 +2,7 @@ lib_platform ============ -Version v1.2.5 as of 2020-08-01 see `Changelog`_ +Version v1.2.6 as of 2020-08-08 see `Changelog`_ |travis_build| |license| |jupyter| |pypi| @@ -54,7 +54,7 @@ Python version required: 3.6.0 or newer tested on linux "bionic" with python 3.6, 3.7, 3.8, 3.8-dev, pypy3 - architectures: amd64, ppc64le, s390x, arm64 -`100% code coverage `_, codestyle checking ,mypy static type checking ,tested under `Linux, macOS, Windows `_, automatic daily builds and monitoring +`100% code coverage `_, flake8 style checking ,mypy static type checking ,tested under `Linux, macOS, Windows `_, automatic daily builds and monitoring ---- @@ -154,32 +154,20 @@ Installation and Upgrade python -m pip --upgrade pip python -m pip --upgrade setuptools - python -m pip --upgrade wheel - to install the latest release from PyPi via pip (recommended): .. code-block:: bash - # install latest release from PyPi python -m pip install --upgrade lib_platform - # test latest release from PyPi without installing (can be skipped) - python -m pip install lib_platform --install-option test - -- to install the latest development version from github via pip: +- to install the latest version from github via pip: .. code-block:: bash - # normal install python -m pip install --upgrade git+https://github.com/bitranox/lib_platform.git - # to test without installing (can be skipped) - python -m pip install git+https://github.com/bitranox/lib_platform.git --install-option test - - # to install and upgrade all dependencies regardless of version number - python -m pip install --upgrade git+https://github.com/bitranox/lib_platform.git --upgrade-strategy eager - - include it into Your requirements.txt: @@ -196,7 +184,6 @@ Installation and Upgrade python -m pip install --upgrade -r //requirements.txt - - to install the latest development version from source code: .. code-block:: bash @@ -204,11 +191,6 @@ Installation and Upgrade # cd ~ $ git clone https://github.com/bitranox/lib_platform.git $ cd lib_platform - - # to test without installing (can be skipped) - python setup.py test - - # normal install python setup.py install - via makefile: @@ -269,6 +251,14 @@ Changelog - new MINOR version for added functionality in a backwards compatible manner - new PATCH version for backwards compatible bug fixes +v1.2.6 +-------- +2020-08-08: service release + - fix documentation + - fix travis + - deprecate pycodestyle + - implement flake8 + v1.2.5 --------- 2020-08-01: fix pypi deploy diff --git a/conftest.py b/conftest.py index 816f30a..497a2cf 100644 --- a/conftest.py +++ b/conftest.py @@ -1,7 +1,6 @@ -import platform from typing import List -collect_ignore = ['setup.py'] +collect_ignore: List[str] = [] def pytest_cmdline_preparse(args: List[str]) -> None: @@ -16,13 +15,5 @@ def pytest_cmdline_preparse(args: List[str]) -> None: args[:] = ["-n", str(num)] + args """ - additional_mypy_args: List[str] = list() - additional_pycodestyle_args: List[str] = list() - - # add mypy option if not pypy - # if platform.python_implementation() != "PyPy" and sys.version_info >= (3, 5) and sys.version_info != (3, 6): # type: ignore - if platform.python_implementation() != "PyPy": - additional_mypy_args = ['--mypy'] - - additional_pycodestyle_args = ['--pycodestyle'] - args[:] = list(set(args + additional_mypy_args + additional_pycodestyle_args)) + additional_pytest_args: List[str] = [] + args[:] = list(set(args + additional_pytest_args)) diff --git a/lib_platform/__init__conf__.py b/lib_platform/__init__conf__.py index 9278482..c316c73 100644 --- a/lib_platform/__init__conf__.py +++ b/lib_platform/__init__conf__.py @@ -1,6 +1,6 @@ name = 'lib_platform' title = 'some platform related functions, which also work correctly on wine' -version = 'v1.2.5' +version = 'v1.2.6' url = 'https://github.com/bitranox/lib_platform' author = 'Robert Nowotny' author_email = 'bitranox@gmail.com' @@ -14,7 +14,7 @@ def print_info() -> None: some platform related functions, which also work correctly on wine - Version : v1.2.5 + Version : v1.2.6 Url : https://github.com/bitranox/lib_platform Author : Robert Nowotny Email : bitranox@gmail.com""") diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index 8b4319d..0000000 --- a/mypy.ini +++ /dev/null @@ -1,7 +0,0 @@ -[mypy] -verbosity=0 -warn_unused_configs = True -ignore_missing_imports = True -no_implicit_optional = True -no_strict_optional = True -show_error_context = True diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..ad4b2d5 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,7 @@ + +[tool.black] +line-length = 88 +target-version = ['py36'] +# Note that you have to use single-quoted strings in TOML for regular expressions +include = '\.pyi?$' +exclude = '/(\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|_build|buck-out|build|dist)/' diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 5df4c41..0000000 --- a/pytest.ini +++ /dev/null @@ -1,18 +0,0 @@ -[pytest] - -# python_files = *.py # we dont need to discover all python files - doctests will be discovered - -addopts = -vvl - --doctest-modules -# --cov # we dont need coverage on setup.py test - we do it in the travis.yaml -# --pycodestyle # this option will be added in conftest.py for python 3.x -# --pep8 # this option will be added in conftest.py for python 2.x -# --mypy # this option will be added in conftest.py if not pypy -# -n # this option will be added in conftest.py if pytest-xdist plugin is available -# # = cpu_count() / 2 (minimum 1) for parallel testing - - -doctest_optionflags = NORMALIZE_WHITESPACE ELLIPSIS ALLOW_UNICODE ALLOW_BYTES IGNORE_EXCEPTION_DETAIL -log_cli = True -# this log level is used to intentionally log on pytest -log_cli_level = CRITICAL diff --git a/requirements_test.txt b/requirements_test.txt index c56d260..b793f92 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,10 +1,13 @@ ## Test Requirements ## following Requirements will be installed temporarily for ## "setup.py install test" or "pip install --install-option test" +black ; platform_python_implementation != "PyPy" +black==19.3b0 ; platform_python_implementation == "PyPy" +codecov coloredlogs -mypy ; platform_python_implementation != "PyPy" -pytest==5.4 -pytest-pycodestyle ; python_version >= "3.5" -pytest-mypy ; platform_python_implementation != "PyPy" and python_version >= "3.5" -pytest-runner +coverage dill +flake8 +mypy ; platform_python_implementation != "PyPy" +pytest +pytest-cov diff --git a/setup.cfg b/setup.cfg index 87219bc..fdec284 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,19 @@ -[aliases] -test=pytest - -[pycodestyle] +[flake8] max_line_length = 160 -ignore = E402, E123 +ignore = E123, E203, E402, F401, F403, F405, W503 +exclude = .git, __pycache__, build, dist, .eggs, .hg, .mypy_cache, .nox, .tox, .venv, _build, buck-out +max-complexity = 20 + +[mypy] +verbosity=0 +warn_unused_configs = True +ignore_missing_imports = True +no_implicit_optional = True +no_strict_optional = True +show_error_context = True + +[tool:pytest] +addopts = -vvl --doctest-modules +doctest_optionflags = NORMALIZE_WHITESPACE ELLIPSIS ALLOW_UNICODE ALLOW_BYTES IGNORE_EXCEPTION_DETAIL +log_cli = True +log_cli_level = CRITICAL diff --git a/setup.py b/setup.py index e62e33f..b7e4215 100644 --- a/setup.py +++ b/setup.py @@ -1,25 +1,24 @@ -""" -Setuptools entry point. -see : https://docs.python.org/3.8/distutils/setupscript.html -""" +#!/usr/bin/env python3 import codecs import os import pathlib from typing import Any, List, Dict -from setuptools import setup # type: ignore +from setuptools import setup # type: ignore from setuptools import find_packages def is_travis_deploy() -> bool: - if os.getenv('DEPLOY_SDIST', '') or os.getenv('DEPLOY_WHEEL', ''): + if os.getenv("DEPLOY_SDIST", "") or os.getenv("DEPLOY_WHEEL", ""): return is_tagged_commit() + else: + return False def is_tagged_commit() -> bool: - if 'TRAVIS_TAG' in os.environ: - if os.environ['TRAVIS_TAG']: + if "TRAVIS_TAG" in os.environ: + if os.environ["TRAVIS_TAG"]: return True return False @@ -30,20 +29,21 @@ def strip_links_from_required(l_required: List[str]) -> List[str]: >>> assert strip_links_from_required(required) == ['lib_regexp', 'test'] """ - l_req_stripped = list() # type: List[str] + l_req_stripped: List[str] = list() for req in l_required: - req_stripped = req.split('@')[0].strip() + req_stripped = req.split("@")[0].strip() l_req_stripped.append(req_stripped) return l_req_stripped -long_description = 'some platform related functions, which also work correctly on wine' # will be overwritten with long_description if exists ! -path_readme = pathlib.Path(__file__).parent / 'README.rst' +# will be overwritten with long_description if exists ! +long_description = "some platform related functions, which also work correctly on wine" +path_readme = pathlib.Path(__file__).parent / "README.rst" if path_readme.exists(): # noinspection PyBroadException try: - readme_content = codecs.open(str(path_readme), encoding='utf-8').read() + readme_content = codecs.open(str(path_readme), encoding="utf-8").read() long_description = readme_content except Exception: pass @@ -55,7 +55,9 @@ def get_requirements_from_file(requirements_filename: str) -> List[str]: """ l_requirements = list() try: - with open(str(pathlib.Path(__file__).parent / requirements_filename), mode='r') as requirements_file: + with open( + str(pathlib.Path(__file__).parent / requirements_filename), mode="r" + ) as requirements_file: for line in requirements_file: line_data = get_line_data(line) if line_data: @@ -67,13 +69,13 @@ def get_requirements_from_file(requirements_filename: str) -> List[str]: def get_line_data(line: str) -> str: line = line.strip() - if '#' in line: - line = line.split('#', 1)[0].strip() + if "#" in line: + line = line.split("#", 1)[0].strip() return line -tests_require = get_requirements_from_file('requirements_test.txt') -install_requires = get_requirements_from_file('requirements.txt') +tests_require = get_requirements_from_file("requirements_test.txt") +install_requires = get_requirements_from_file("requirements.txt") setup_requires = list(set(tests_require + install_requires)) # for deploy on pypi we must not rely on imports from github @@ -83,28 +85,40 @@ def get_line_data(line: str) -> str: install_requires = strip_links_from_required(install_requires) setup_kwargs: Dict[str, Any] = dict() -setup_kwargs['name'] = 'lib_platform' -setup_kwargs['version'] = 'v1.2.5' -setup_kwargs['url'] = 'https://github.com/bitranox/lib_platform' -setup_kwargs['packages'] = find_packages() -setup_kwargs['package_data'] = {'lib_platform': ['py.typed', '*.pyi', '__init__.pyi']} -setup_kwargs['description'] = 'some platform related functions, which also work correctly on wine' -setup_kwargs['long_description'] = long_description -setup_kwargs['long_description_content_type'] = 'text/x-rst' -setup_kwargs['author'] = 'Robert Nowotny' -setup_kwargs['author_email'] = 'bitranox@gmail.com' -setup_kwargs['classifiers'] = ['Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', 'License :: OSI Approved :: MIT License', 'Natural Language :: English', 'Operating System :: OS Independent', 'Programming Language :: Python', 'Topic :: Software Development :: Libraries :: Python Modules'] -setup_kwargs['entry_points'] = {'console_scripts': ['lib_platform = lib_platform.lib_platform_cli:cli_main']} +setup_kwargs["name"] = "lib_platform" +setup_kwargs["version"] = "v1.2.6" +setup_kwargs["url"] = "https://github.com/bitranox/lib_platform" +setup_kwargs["packages"] = find_packages() +setup_kwargs["package_data"] = {"lib_platform": ["py.typed", "*.pyi", "__init__.pyi"]} +setup_kwargs[ + "description" +] = "some platform related functions, which also work correctly on wine" +setup_kwargs["long_description"] = long_description +setup_kwargs["long_description_content_type"] = "text/x-rst" +setup_kwargs["author"] = "Robert Nowotny" +setup_kwargs["author_email"] = "bitranox@gmail.com" +setup_kwargs["classifiers"] = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Natural Language :: English", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Topic :: Software Development :: Libraries :: Python Modules", +] +setup_kwargs["entry_points"] = { + "console_scripts": ["lib_platform = lib_platform.lib_platform_cli:cli_main"] +} # minimally needs to run tests - no project requirements here -setup_kwargs['tests_require'] = tests_require +setup_kwargs["tests_require"] = tests_require # specify what a project minimally needs to run correctly -setup_kwargs['install_requires'] = install_requires +setup_kwargs["install_requires"] = install_requires # minimally needs to run the setup script, dependencies needs also to put here for "setup.py install test" # dependencies must not be put here for pip install -setup_kwargs['setup_requires'] = setup_requires -setup_kwargs['python_requires'] = ">=3.6.0" -setup_kwargs['zip_safe'] = False +setup_kwargs["setup_requires"] = setup_requires +setup_kwargs["python_requires"] = ">=3.6.0" +setup_kwargs["zip_safe"] = False -if __name__ == '__main__': +if __name__ == "__main__": setup(**setup_kwargs) diff --git a/tests/local_testscripts/lib_bash_functions.sh b/tests/local_testscripts/lib_bash_functions.sh index 98a6869..aeb35b8 100644 --- a/tests/local_testscripts/lib_bash_functions.sh +++ b/tests/local_testscripts/lib_bash_functions.sh @@ -104,6 +104,7 @@ function install_clean_virtual_environment() { virtualenv ~/venv } + function cleanup() { trap '' 2 # disable Ctrl+C delete_virtual_environment @@ -112,37 +113,42 @@ function cleanup() { trap 2 # enable Ctrl+C } -function run_pytest() { - # run pytest, accepts additional pytest parameters like --disable-warnings and so on - my_banner "running pytest with settings from pytest.ini, mypy.ini and conftest.py" - if ! python3 -m pytest "${project_root_dir}" "$@"; then - my_banner_warning "pytest ERROR" + +function run_flake8_tests() { + # run flake8, settings from setup.cfg + my_banner "running flake8 with settings from ${project_root_dir}/setup.cfg" + if ! python3 -m flake8 --append-config="${project_root_dir}/setup.cfg" "$@" "${project_root_dir}"; then + my_banner_warning "flake8 ERROR" beep sleep "${sleeptime_on_error}" return 1 fi } -function mypy_strict() { - my_banner "mypy strict" - if ! python3 -m mypy "${project_root_dir}" --strict --implicit-reexport --follow-imports=silent --no-warn-unused-ignores; then - my_banner_warning "mypy strict ERROR" + +function run_mypy_tests() { + my_banner "mypy tests" + if ! python3 -m mypy "${project_root_dir}" --follow-imports=normal --implicit-reexport --no-warn-unused-ignores --strict; then + my_banner_warning "mypy tests ERROR" beep sleep "${sleeptime_on_error}" return 1 fi } -function mypy_strict_with_imports() { - my_banner "mypy strict including imports" - if ! python3 -m mypy "${project_root_dir}" --strict --no-warn-unused-ignores --implicit-reexport --follow-imports=normal; then - my_banner_warning "mypy strict including imports ERROR" + +function run_pytest() { + # run pytest, accepts additional pytest parameters like --disable-warnings and so on + my_banner "running pytest with settings from pytest.ini, mypy.ini and conftest.py" + if ! python3 -m pytest "${project_root_dir}" "$@" --cov=lib_platform; then + my_banner_warning "pytest ERROR" beep sleep "${sleeptime_on_error}" return 1 fi } + function install_pip_requirements_venv() { if test -f "${project_root_dir}/requirements.txt on virtual environment"; then my_banner "pip install -r requirements.txt" @@ -156,6 +162,7 @@ function install_pip_requirements_venv() { fi } + function setup_install_venv() { if test -f "${project_root_dir}/setup.py"; then my_banner "setup.py install on virtual environment" @@ -170,6 +177,7 @@ function setup_install_venv() { fi } + function test_commandline_interface_venv() { # this will fail if rotek lib directory is in the path - keep this as a reminder my_banner "test commandline interface on virtual environment" @@ -183,6 +191,7 @@ function test_commandline_interface_venv() { fi } + function test_setup_test_venv() { if test -f "${project_root_dir}/setup.py"; then my_banner "setup.py test" @@ -197,5 +206,6 @@ function test_setup_test_venv() { fi } + # cleanup on cntrl-c trap cleanup EXIT diff --git a/tests/local_testscripts/run_pytest.sh b/tests/local_testscripts/run_pytest.sh index dc2b235..a9dafd7 100644 --- a/tests/local_testscripts/run_pytest.sh +++ b/tests/local_testscripts/run_pytest.sh @@ -2,6 +2,9 @@ own_dir="$( cd "$(dirname "${BASH_SOURCE[0]}")" || exit && pwd -P )" # this gives the full path, even for sourced scripts +DO_PYTEST="True" + + # shellcheck disable=SC2050 if [[ "True" != "True" ]]; then echo "exit - ${BASH_SOURCE[0]} is not configured by PizzaCutter" @@ -21,10 +24,12 @@ function do_tests { # that folder is in the mypy path # a more loose setting here would be: # if ! run_pytest --disable-warnings --follow-imports=silent; then - if ! run_pytest; then - banner_warning "TESTS FAILED for ${project_root_dir}" - exit 1 - fi + if [ "${DO_PYTEST}" == "True" ]; then + if ! run_pytest --disable-warnings; then + banner_warning "TESTS FAILED for ${project_root_dir}" + exit 1 + fi + fi } do_tests diff --git a/tests/local_testscripts/run_testloop.sh b/tests/local_testscripts/run_testloop.sh index 5dd61ac..222d298 100644 --- a/tests/local_testscripts/run_testloop.sh +++ b/tests/local_testscripts/run_testloop.sh @@ -10,7 +10,9 @@ fi # shellcheck disable=SC1090 source "${own_dir}/lib_bash_functions.sh" project_root_dir="${project_root_dir}" -do_mypy_tests="True" # this is set py PizzaCutter +DO_FLAKE8_TESTS="True" +DO_MYPY_TESTS="True" +DO_PYTEST="True" # cleanup on cntrl-c trap cleanup EXIT @@ -21,20 +23,25 @@ function pytest_loop { while true; do banner "Project Root Dir: ${project_root_dir}" cleanup - # pytest options can be passed to run_pytest like --disable-warnings - # --log-cli-level=ERROR shows error in pytest if we log to logger.ERROR - # if ! run_pytest --disable-warnings --log-cli-level=ERROR; then continue; fi - if ! run_pytest --disable-warnings; then continue; fi - - if [ "${do_mypy_tests}" == "True" ]; then - if ! mypy_strict; then continue; fi - if ! mypy_strict_with_imports; then continue; fi + + # we prefer to run tests on its own, not within pytest, due to shaky and outdated pytest plugins + if [ "${DO_FLAKE8_TESTS}" == "True" ]; then + if ! run_flake8_tests; then continue; fi + fi + + # we prefer to run tests on its own, not within pytest, due to shaky and outdated pytest plugins + if [ "${DO_MYPY_TESTS}" == "True" ]; then + if ! run_mypy_tests; then continue; fi + fi + + if [ "${DO_PYTEST}" == "True" ]; then + if ! run_pytest --disable-warnings; then continue; fi fi - if ! install_pip_requirements_venv; then continue; fi + # if ! install_pip_requirements_venv; then continue; fi + # if ! test_setup_test_venv; then continue; fi if ! setup_install_venv; then continue; fi if ! test_commandline_interface_venv; then continue; fi - if ! test_setup_test_venv; then continue; fi banner "ALL TESTS PASSED for ${project_root_dir}" banner "ALL TESTS PASSED for ${project_root_dir}" diff --git a/tests/test_cli.py b/tests/test_cli.py index eb37d82..fc23455 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -11,11 +11,11 @@ path_cli_command = pathlib.Path(__file__).resolve().parent.parent / package_dir / cli_filename -def call_cli_command(commandline_args: str = '', log: bool = True) -> bool: +def call_cli_command(commandline_args: str = '') -> bool: command = ' '.join([sys.executable, str(path_cli_command), commandline_args]) try: subprocess.run(command, shell=True, check=True) - except subprocess.CalledProcessError as exc: + except subprocess.CalledProcessError: return False return True diff --git a/tests/test_lib_platform.py b/tests/test_lib_platform.py index a2f248d..c6b124f 100644 --- a/tests/test_lib_platform.py +++ b/tests/test_lib_platform.py @@ -126,7 +126,7 @@ def test_function_to_pickle() -> None: def test_if_pickable() -> None: pickled_object = dill.dumps(test_function_to_pickle) - unpickled_object = dill.loads(pickled_object) + dill.loads(pickled_object) def test_fake_xp_function() -> str: