diff --git a/.github/workflows/ApplicationTesting.yml b/.github/workflows/ApplicationTesting.yml index a23833d..e60c096 100644 --- a/.github/workflows/ApplicationTesting.yml +++ b/.github/workflows/ApplicationTesting.yml @@ -82,7 +82,7 @@ jobs: steps: - name: ⏬ Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: 📥 Download artifacts '${{ inputs.wheel }}' from 'Package' job uses: actions/download-artifact@v3 diff --git a/.github/workflows/BuildTheDocs.yml b/.github/workflows/BuildTheDocs.yml index cade896..c2f1d6e 100644 --- a/.github/workflows/BuildTheDocs.yml +++ b/.github/workflows/BuildTheDocs.yml @@ -38,7 +38,7 @@ jobs: steps: - name: ⏬ Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: 🛳️ Build documentation uses: buildthedocs/btd@v0 diff --git a/.github/workflows/CoverageCollection.yml b/.github/workflows/CoverageCollection.yml index fc8f08d..9c3e4e3 100644 --- a/.github/workflows/CoverageCollection.yml +++ b/.github/workflows/CoverageCollection.yml @@ -67,7 +67,7 @@ jobs: steps: - name: ⏬ Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: 🐍 Setup Python ${{ inputs.python_version }} uses: actions/setup-python@v4 @@ -131,6 +131,7 @@ jobs: continue-on-error: true run: | export ENVIRONMENT_NAME="Linux (x86-64)" + export PYTHONPATH=$(pwd) ABSDIR=$(pwd) cd "${{ inputs.tests_directory || '.' }}" [ -n '${{ inputs.coverage_config }}' ] && PYCOV_ARGS="--cov-config=${ABSDIR}/${{ inputs.coverage_config }}" || unset PYCOV_ARGS diff --git a/.github/workflows/Package.yml b/.github/workflows/Package.yml index fc45356..6ae3812 100644 --- a/.github/workflows/Package.yml +++ b/.github/workflows/Package.yml @@ -48,7 +48,7 @@ jobs: steps: - name: ⏬ Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: 🐍 Setup Python ${{ inputs.python_version }} uses: actions/setup-python@v4 diff --git a/.github/workflows/Pipeline.yml b/.github/workflows/Pipeline.yml index ecb5552..7768911 100644 --- a/.github/workflows/Pipeline.yml +++ b/.github/workflows/Pipeline.yml @@ -1,4 +1,5 @@ -name: Pipeline +#name: Pipeline +name: Documentation on: push: diff --git a/.github/workflows/PublishCoverageResults.yml b/.github/workflows/PublishCoverageResults.yml new file mode 100644 index 0000000..017da5f --- /dev/null +++ b/.github/workflows/PublishCoverageResults.yml @@ -0,0 +1,67 @@ +# ==================================================================================================================== # +# Authors: # +# Patrick Lehmann # +# # +# ==================================================================================================================== # +# Copyright 2020-2023 The pyTooling Authors # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +# # +# SPDX-License-Identifier: Apache-2.0 # +# ==================================================================================================================== # +name: Publish Unit Test Results + +on: + workflow_call: + inputs: + report_files: + description: 'Pattern of report files to upload. Can be a comma separated list.' + required: false + default: 'artifacts/**/*.xml' + type: string + secrets: + codacy_token: + description: 'Token to push result to codacy.' + required: true + +jobs: + PublishTestResults: + name: 📊 Publish Test Results + runs-on: ubuntu-latest + if: always() + + steps: + - name: ⏬ Checkout repository + uses: actions/checkout@v4 + + - name: Download Artifacts + uses: actions/download-artifact@v3 + with: + path: artifacts + + - name: 📊 Publish code coverage at CodeCov + if: inputs.CodeCov == true + continue-on-error: true + uses: codecov/codecov-action@v3 + with: + files: ${{ steps.getVariables.outputs.coverage_report_xml }} + flags: unittests + env_vars: PYTHON + + - name: 📉 Publish code coverage at Codacy + if: inputs.Codacy == true + continue-on-error: true + uses: codacy/codacy-coverage-reporter-action@v1 + with: + project-token: ${{ secrets.codacy_token }} + coverage-reports: ${{ steps.getVariables.outputs.coverage_report_xml }} diff --git a/.github/workflows/PublishTestResults.yml b/.github/workflows/PublishTestResults.yml index e93b3ba..35771da 100644 --- a/.github/workflows/PublishTestResults.yml +++ b/.github/workflows/PublishTestResults.yml @@ -39,7 +39,7 @@ jobs: steps: - name: ⏬ Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Download Artifacts uses: actions/download-artifact@v3 diff --git a/.github/workflows/PublishToGitHubPages.yml b/.github/workflows/PublishToGitHubPages.yml index bd22990..445a25c 100644 --- a/.github/workflows/PublishToGitHubPages.yml +++ b/.github/workflows/PublishToGitHubPages.yml @@ -48,7 +48,7 @@ jobs: steps: - name: ⏬ Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: 📥 Download artifacts '${{ inputs.doc }}' from 'BuildTheDocs' job uses: actions/download-artifact@v3 diff --git a/.github/workflows/StaticTypeCheck.yml b/.github/workflows/StaticTypeCheck.yml index 4113c25..18af69e 100644 --- a/.github/workflows/StaticTypeCheck.yml +++ b/.github/workflows/StaticTypeCheck.yml @@ -67,7 +67,7 @@ jobs: steps: - name: ⏬ Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: 🐍 Setup Python ${{ inputs.python_version }} uses: actions/setup-python@v4 diff --git a/.github/workflows/TestReleaser.yml b/.github/workflows/TestReleaser.yml index dc2252e..70f46b4 100644 --- a/.github/workflows/TestReleaser.yml +++ b/.github/workflows/TestReleaser.yml @@ -45,7 +45,7 @@ jobs: env: DOCKER_BUILDKIT: 1 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Build container image run: docker build -t ghcr.io/pytooling/releaser -f releaser/Dockerfile releaser @@ -62,7 +62,7 @@ jobs: Composite: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: echo "Build some tool and generate some (versioned) artifacts" > artifact-$(date -u +"%Y-%m-%dT%H-%M-%SZ").txt @@ -122,7 +122,7 @@ jobs: - Composite runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: echo "Build some tool and generate some (versioned) artifacts" > artifact-$(date -u +"%Y-%m-%dT%H-%M-%SZ").txt diff --git a/.github/workflows/UnitTesting.yml b/.github/workflows/UnitTesting.yml index 4505de7..18e91d2 100644 --- a/.github/workflows/UnitTesting.yml +++ b/.github/workflows/UnitTesting.yml @@ -77,7 +77,7 @@ jobs: steps: - name: ⏬ Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Compute pacman/pacboy packages id: pacboy @@ -192,19 +192,23 @@ jobs: if: matrix.system == 'windows' run: | $env:ENVIRONMENT_NAME = "${{ matrix.envname }}" + $env:PYTHONPATH = (Get-Location).ToString() cd "${{ inputs.tests_directory || '.' }}" $PYTEST_ARGS = if ("${{ inputs.artifact }}") { "--junitxml=TestReportSummary.xml" } else { "" } - python -m pytest -rA ${{ inputs.unittest_directory }} $PYTEST_ARGS --color=yes + Write-Host "python -m pytest -rA $PYTEST_ARGS --color=yes ${{ inputs.unittest_directory }}" + python -m pytest -rA $PYTEST_ARGS --color=yes ${{ inputs.unittest_directory }} - name: ☑ Run unit tests (Ubuntu/macOS) if: matrix.system != 'windows' run: | export ENVIRONMENT_NAME="${{ matrix.envname }}" + export PYTHONPATH=$(pwd) ABSDIR=$(pwd) cd "${{ inputs.tests_directory || '.' }}" [ -n '${{ inputs.coverage_config }}' ] && PYCOV_ARGS="--cov-config=${ABSDIR}/${{ inputs.coverage_config }}" || unset PYCOV_ARGS [ -n '${{ inputs.artifact }}' ] && PYTEST_ARGS='--junitxml=TestReportSummary.xml' || unset PYTEST_ARGS - python -m pytest -rA ${{ inputs.unittest_directory }} $PYTEST_ARGS --color=yes + echo "python -m pytest -rA $PYTEST_ARGS --color=yes ${{ inputs.unittest_directory }}" + python -m pytest -rA $PYTEST_ARGS --color=yes ${{ inputs.unittest_directory }} - name: 📤 Upload 'TestReportSummary.xml' artifact if: inputs.artifact != '' diff --git a/.github/workflows/VerifyDocs.yml b/.github/workflows/VerifyDocs.yml index de281ff..1c4c47f 100644 --- a/.github/workflows/VerifyDocs.yml +++ b/.github/workflows/VerifyDocs.yml @@ -39,7 +39,7 @@ jobs: steps: - name: ⏬ Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: 🐍 Setup Python uses: actions/setup-python@v4 diff --git a/.github/workflows/_Checking_Pipeline.yml b/.github/workflows/_Checking_Pipeline.yml new file mode 100644 index 0000000..98be005 --- /dev/null +++ b/.github/workflows/_Checking_Pipeline.yml @@ -0,0 +1,155 @@ +name: Verification of Complete Pipeline + +on: + push: + workflow_dispatch: + +jobs: + UnitTestingParams: + uses: pyTooling/Actions/.github/workflows/Parameters.yml@cov + with: + name: pyDummy + python_version_list: "3.11" +# python_version_list: "3.7 3.8 pypy-3.8 3.9 pypy-3.9 3.10 3.11" + exclude_list: "windows:pypy-3.8 windows:pypy-3.9" +# disable_list: "windows:3.11" + + PlatformTestingParams: + uses: pyTooling/Actions/.github/workflows/Parameters.yml@cov + with: + name: Platform + python_version_list: "" + system_list: "ubuntu" +# system_list: "ubuntu windows macos mingw32 mingw64 clang64 ucrt64" + + UnitTesting: + uses: pyTooling/Actions/.github/workflows/UnitTesting.yml@cov + needs: + - UnitTestingParams + with: + jobs: ${{ needs.UnitTestingParams.outputs.python_jobs }} + artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_xml }} + + PlatformTesting: + uses: pyTooling/Actions/.github/workflows/UnitTesting.yml@cov + needs: + - PlatformTestingParams + with: + jobs: ${{ needs.PlatformTestingParams.outputs.python_jobs }} + tests_directory: "" + unittest_directory: tests/unit/Platform + artifact: ${{ fromJson(needs.PlatformTestingParams.outputs.artifact_names).unittesting_xml }} + + Coverage: + uses: pyTooling/Actions/.github/workflows/CoverageCollection.yml@cov + needs: + - UnitTestingParams + with: + python_version: ${{ needs.UnitTestingParams.outputs.python_version }} + artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_html }} + secrets: + codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} + + PublishCoverageResults: + uses: pyTooling/Actions/.github/workflows/PublishCoverageResults.yml@cov + needs: + - UnitTesting + - Coverage + secrets: + codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} + + StaticTypeCheck: + uses: pyTooling/Actions/.github/workflows/StaticTypeCheck.yml@cov + needs: + - UnitTestingParams + with: + python_version: ${{ needs.UnitTestingParams.outputs.python_version }} + commands: | + mypy --html-report htmlmypy -p pyDummy + html_report: 'htmlmypy' + html_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).statictyping_html }} + + PublishTestResults: + uses: pyTooling/Actions/.github/workflows/PublishTestResults.yml@cov + needs: + - UnitTesting + + Package: + uses: pyTooling/Actions/.github/workflows/Package.yml@cov + needs: + - UnitTestingParams + - Coverage + - PlatformTesting + with: + python_version: ${{ needs.UnitTestingParams.outputs.python_version }} + artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).package_all }} + + Release: + uses: pyTooling/Actions/.github/workflows/Release.yml@cov + if: startsWith(github.ref, 'refs/tags') + needs: + - UnitTesting + - Coverage + - StaticTypeCheck + - Package + + PublishOnPyPI: + uses: pyTooling/Actions/.github/workflows/PublishOnPyPI.yml@cov + if: startsWith(github.ref, 'refs/tags') + needs: + - UnitTestingParams + - Release + - Package + with: + python_version: ${{ needs.UnitTestingParams.outputs.python_version }} + requirements: -r dist/requirements.txt + artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).package_all }} + secrets: + PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} + +# VerifyDocs: +# uses: pyTooling/Actions/.github/workflows/VerifyDocs.yml@cov +# needs: +# - UnitTestingParams +# with: +# python_version: ${{ needs.UnitTestingParams.outputs.python_version }} + +# BuildTheDocs: +# uses: pyTooling/Actions/.github/workflows/BuildTheDocs.yml@cov +# needs: +# - UnitTestingParams +## - VerifyDocs +# with: +# artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).documentation_html }} + + PublishToGitHubPages: + uses: pyTooling/Actions/.github/workflows/PublishToGitHubPages.yml@cov + needs: + - UnitTestingParams +# - BuildTheDocs + - Coverage + - StaticTypeCheck + with: + doc: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).documentation_html }} + coverage: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_html }} + typing: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).statictyping_html }} + + ArtifactCleanUp: + uses: pyTooling/Actions/.github/workflows/ArtifactCleanUp.yml@cov + needs: + - UnitTestingParams + - UnitTesting + - PlatformTesting + - Coverage + - StaticTypeCheck +# - BuildTheDocs + - PublishToGitHubPages + - PublishCoverageResults + - PublishTestResults + with: + package: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).package_all }} + remaining: | + ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_xml }}-* + ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_html }} + ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).statictyping_html }} + ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).documentation_html }} diff --git a/doc/Action/Releaser.rst b/doc/Action/Releaser.rst index 95a4212..d91b04f 100644 --- a/doc/Action/Releaser.rst +++ b/doc/Action/Releaser.rst @@ -85,7 +85,7 @@ The following block shows a minimal YAML workflow file: steps: # Clone repository - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # Build your application, tool, artifacts, etc. - name: Build diff --git a/pyDummy/__init__.py b/pyDummy/__init__.py new file mode 100644 index 0000000..83a8d41 --- /dev/null +++ b/pyDummy/__init__.py @@ -0,0 +1,51 @@ +# ==================================================================================================================== # +# _____ _ _ _ _ _ # +# _ __ _ |_ _|__ ___ | (_)_ __ __ _ / \ ___| |_(_) ___ _ __ ___ # +# | '_ \| | | || |/ _ \ / _ \| | | '_ \ / _` | / _ \ / __| __| |/ _ \| '_ \/ __| # +# | |_) | |_| || | (_) | (_) | | | | | | (_| |_ / ___ \ (__| |_| | (_) | | | \__ \ # +# | .__/ \__, ||_|\___/ \___/|_|_|_| |_|\__, (_)_/ \_\___|\__|_|\___/|_| |_|___/ # +# |_| |___/ |___/ # +# ==================================================================================================================== # +# Authors: # +# Patrick Lehmann # +# # +# License: # +# ==================================================================================================================== # +# Copyright 2017-2023 Patrick Lehmann - Bötzingen, Germany # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +# # +# SPDX-License-Identifier: Apache-2.0 # +# ==================================================================================================================== # +# +__author__ = "Patrick Lehmann" +__email__ = "Paebbels@gmail.com" +__copyright__ = "2017-2023, Patrick Lehmann" +__license__ = "Apache License, Version 2.0" +__version__ = "0.1.0" +__keywords__ = ["dummy"] +__issue_tracker__ = "https://GitHub.com/pyTooling/Actions/issues" + +from pyTooling.Decorators import export + + +@export +class Application: + _value: int + + def __init__(self) -> None: + self._value = 1 + + @property + def Value(self) -> int: + return self._value diff --git a/pyDummy/py.typed b/pyDummy/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..dca4a29 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,60 @@ +[build-system] +requires = [ + "setuptools >= 68.0.0", + "wheel >= 0.40.0", + "pyTooling >= 5.0.0" +] +build-backend = "setuptools.build_meta" + +[tool.black] +line-length = 120 + +[tool.mypy] +files = ["pyDummy"] +python_version = "3.11" +#ignore_missing_imports = true +strict = true +pretty = true +show_error_context = true +show_error_codes = true +namespace_packages = true +html_report = "report/typing" + +[tool.pytest.ini_options] +# Don't set 'python_classes = *' otherwise, pytest doesn't search for classes +# derived from unittest.Testcase +python_files = "*" +python_functions = "test_*" +filterwarnings = [ + "error::DeprecationWarning", + "error::PendingDeprecationWarning" +] + +[tool.coverage.run] +branch = true +omit = [ + "*site-packages*", + "setup.py", + "tests/*" +] + +[tool.coverage.report] +skip_covered = false +skip_empty = true +exclude_lines = [ + "pragma: no cover", + "raise NotImplementedError" +] +omit = [ + "tests/*" +] + +[tool.coverage.xml] +output = "report/coverage/coverage.xml" + +[tool.coverage.json] +output = "report/coverage/coverage.json" + +[tool.coverage.html] +directory = "report/coverage/html" +title="Code Coverage of pyDummy" diff --git a/releaser/README.md b/releaser/README.md index a5b3b1d..33a78cc 100644 --- a/releaser/README.md +++ b/releaser/README.md @@ -79,7 +79,7 @@ jobs: steps: # Clone repository - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # Build your application, tool, artifacts, etc. - name: Build diff --git a/requirements.txt b/requirements.txt index e69de29..4ad7e0b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -0,0 +1 @@ +pyTooling >= 5.0.0, <6.0.0 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..136ae70 --- /dev/null +++ b/setup.py @@ -0,0 +1,50 @@ +# ==================================================================================================================== # +# _____ _ _ _ _ _ # +# _ __ _ |_ _|__ ___ | (_)_ __ __ _ / \ ___| |_(_) ___ _ __ ___ # +# | '_ \| | | || |/ _ \ / _ \| | | '_ \ / _` | / _ \ / __| __| |/ _ \| '_ \/ __| # +# | |_) | |_| || | (_) | (_) | | | | | | (_| |_ / ___ \ (__| |_| | (_) | | | \__ \ # +# | .__/ \__, ||_|\___/ \___/|_|_|_| |_|\__, (_)_/ \_\___|\__|_|\___/|_| |_|___/ # +# |_| |___/ |___/ # +# ==================================================================================================================== # +# Authors: # +# Patrick Lehmann # +# # +# License: # +# ==================================================================================================================== # +# Copyright 2017-2023 Patrick Lehmann - Bötzingen, Germany # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +# # +# SPDX-License-Identifier: Apache-2.0 # +# ==================================================================================================================== # +# +from setuptools import setup + +from pathlib import Path +from pyTooling.Packaging import DescribePythonPackageHostedOnGitHub + +gitHubNamespace = "pyTooling" +packageName = "pyDummy" +packageDirectory = packageName +packageInformationFile = Path(f"{packageDirectory}/__init__.py") + +setup(**DescribePythonPackageHostedOnGitHub( + packageName=packageName, + description="pyDummy is a test package to verify GitHub actions for Python projects.", + gitHubNamespace=gitHubNamespace, + unittestRequirementsFile=Path("tests/requirements.txt"), + sourceFileWithVersion=packageInformationFile, + dataFiles={ + packageName: ["py.typed"] + } +)) diff --git a/tests/requirements.txt b/tests/requirements.txt new file mode 100644 index 0000000..e75ed5e --- /dev/null +++ b/tests/requirements.txt @@ -0,0 +1,13 @@ +-r ../requirements.txt + +# Coverage collection +Coverage >= 7.3 + +# Test Runner +pytest >= 7.4.0 +pytest-cov >= 4.1.0 + +# Static Type Checking +mypy >= 1.5.0 +typing_extensions >= 4.7.1 +lxml>=4.9 diff --git a/tests/unit/Dummy.py b/tests/unit/Dummy.py new file mode 100644 index 0000000..2a5c3e6 --- /dev/null +++ b/tests/unit/Dummy.py @@ -0,0 +1,40 @@ +# ==================================================================================================================== # +# _____ _ _ _ _ _ # +# _ __ _ |_ _|__ ___ | (_)_ __ __ _ / \ ___| |_(_) ___ _ __ ___ # +# | '_ \| | | || |/ _ \ / _ \| | | '_ \ / _` | / _ \ / __| __| |/ _ \| '_ \/ __| # +# | |_) | |_| || | (_) | (_) | | | | | | (_| |_ / ___ \ (__| |_| | (_) | | | \__ \ # +# | .__/ \__, ||_|\___/ \___/|_|_|_| |_|\__, (_)_/ \_\___|\__|_|\___/|_| |_|___/ # +# |_| |___/ |___/ # +# ==================================================================================================================== # +# Authors: # +# Patrick Lehmann # +# # +# License: # +# ==================================================================================================================== # +# Copyright 2017-2023 Patrick Lehmann - Bötzingen, Germany # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +# # +# SPDX-License-Identifier: Apache-2.0 # +# ==================================================================================================================== # +# +from unittest import TestCase + +from pyDummy import Application + + +class Instantiation(TestCase): + def test_Application(self): + app = Application() + + self.assertEqual(1, app.Value) diff --git a/tests/unit/Platform/__init__.py b/tests/unit/Platform/__init__.py new file mode 100644 index 0000000..248a6c3 --- /dev/null +++ b/tests/unit/Platform/__init__.py @@ -0,0 +1,116 @@ +# ==================================================================================================================== # +# _____ _ _ _ _ _ # +# _ __ _ |_ _|__ ___ | (_)_ __ __ _ / \ ___| |_(_) ___ _ __ ___ # +# | '_ \| | | || |/ _ \ / _ \| | | '_ \ / _` | / _ \ / __| __| |/ _ \| '_ \/ __| # +# | |_) | |_| || | (_) | (_) | | | | | | (_| |_ / ___ \ (__| |_| | (_) | | | \__ \ # +# | .__/ \__, ||_|\___/ \___/|_|_|_| |_|\__, (_)_/ \_\___|\__|_|\___/|_| |_|___/ # +# |_| |___/ |___/ # +# ==================================================================================================================== # +# Authors: # +# Patrick Lehmann # +# # +# License: # +# ==================================================================================================================== # +# Copyright 2017-2023 Patrick Lehmann - Bötzingen, Germany # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +# # +# SPDX-License-Identifier: Apache-2.0 # +# ==================================================================================================================== # +# +"""Unit tests for TBD.""" +from os import getenv as os_getenv +from pytest import mark +from unittest import TestCase + +from pyTooling.Platform import Platform + + +if __name__ == "__main__": # pragma: no cover + print("ERROR: you called a testcase declaration file as an executable module.") + print("Use: 'python -m unitest '") + exit(1) + + +class AnyPlatform(TestCase): + expected = os_getenv("ENVIRONMENT_NAME", default="Windows (x86-64)") + + @mark.skipif(os_getenv("ENVIRONMENT_NAME", "skip") == "skip", reason="Skipped when environment variable 'ENVIRONMENT_NAME' isn't set.") + def test_PlatformString(self) -> None: + platform = Platform() + + print() + print(platform) + + @mark.skipif("Linux (x86-64)" != os_getenv("ENVIRONMENT_NAME", "skip"), reason=f"Skipped 'test_NativeLinux' when environment variable 'ENVIRONMENT_NAME' doesn't match. {os_getenv('ENVIRONMENT_NAME', 'skip')}") + def test_NativeLinux(self) -> None: + platform = Platform() + + print() + print(platform) + + @mark.skipif("MacOS (x86-64)" != os_getenv("ENVIRONMENT_NAME", "skip"), reason=f"Skipped 'test_NativeMacOS' when environment variable 'ENVIRONMENT_NAME' doesn't match. {os_getenv('ENVIRONMENT_NAME', 'skip')}") + def test_NativeMacOS(self) -> None: + platform = Platform() + + print() + print(platform) + + @mark.skipif("Windows (x86-64)" != os_getenv("ENVIRONMENT_NAME", "skip"), reason=f"Skipped 'test_NativeWindows' when environment variable 'ENVIRONMENT_NAME' doesn't match. {os_getenv('ENVIRONMENT_NAME', 'skip')}") + def test_NativeWindows(self) -> None: + platform = Platform() + + print() + print(platform) + + @mark.skipif("Windows+MSYS2 (x86-64) - MSYS" != os_getenv("ENVIRONMENT_NAME", "skip"), reason=f"Skipped 'test_MSYS' when environment variable 'ENVIRONMENT_NAME' doesn't match. {os_getenv('ENVIRONMENT_NAME', 'skip')}") + def test_MSYS(self) -> None: + platform = Platform() + + print() + print(platform) + + @mark.skipif("Windows+MSYS2 (x86-64) - MinGW32" != os_getenv("ENVIRONMENT_NAME", "skip"), reason=f"Skipped 'test_MinGW32' when environment variable 'ENVIRONMENT_NAME' doesn't match. {os_getenv('ENVIRONMENT_NAME', 'skip')}") + def test_MinGW32(self) -> None: + platform = Platform() + + print() + print(platform) + + @mark.skipif("Windows+MSYS2 (x86-64) - MinGW64" != os_getenv("ENVIRONMENT_NAME", "skip"), reason=f"Skipped 'test_MinGW64' when environment variable 'ENVIRONMENT_NAME' doesn't match. {os_getenv('ENVIRONMENT_NAME', 'skip')}") + def test_MinGW64(self) -> None: + platform = Platform() + + print() + print(platform) + + @mark.skipif("Windows+MSYS2 (x86-64) - UCRT64" != os_getenv("ENVIRONMENT_NAME", "skip"), reason=f"Skipped 'test_UCRT64' when environment variable 'ENVIRONMENT_NAME' doesn't match. {os_getenv('ENVIRONMENT_NAME', 'skip')}") + def test_UCRT64(self) -> None: + platform = Platform() + + print() + print(platform) + + @mark.skipif("Windows+MSYS2 (x86-64) - Clang32" != os_getenv("ENVIRONMENT_NAME", "skip"), reason=f"Skipped 'test_Clang32' when environment variable 'ENVIRONMENT_NAME' doesn't match. {os_getenv('ENVIRONMENT_NAME', 'skip')}") + def test_Clang32(self) -> None: + platform = Platform() + + print() + print(platform) + + @mark.skipif("Windows+MSYS2 (x86-64) - Clang64" != os_getenv("ENVIRONMENT_NAME", "skip"), reason=f"Skipped 'test_Clang64' when environment variable 'ENVIRONMENT_NAME' doesn't match. {os_getenv('ENVIRONMENT_NAME', 'skip')}") + def test_Clang64(self) -> None: + platform = Platform() + + print() + print(platform) diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py new file mode 100644 index 0000000..896d194 --- /dev/null +++ b/tests/unit/__init__.py @@ -0,0 +1,31 @@ +# ==================================================================================================================== # +# _____ _ _ _ _ _ # +# _ __ _ |_ _|__ ___ | (_)_ __ __ _ / \ ___| |_(_) ___ _ __ ___ # +# | '_ \| | | || |/ _ \ / _ \| | | '_ \ / _` | / _ \ / __| __| |/ _ \| '_ \/ __| # +# | |_) | |_| || | (_) | (_) | | | | | | (_| |_ / ___ \ (__| |_| | (_) | | | \__ \ # +# | .__/ \__, ||_|\___/ \___/|_|_|_| |_|\__, (_)_/ \_\___|\__|_|\___/|_| |_|___/ # +# |_| |___/ |___/ # +# ==================================================================================================================== # +# Authors: # +# Patrick Lehmann # +# # +# License: # +# ==================================================================================================================== # +# Copyright 2017-2023 Patrick Lehmann - Bötzingen, Germany # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +# # +# SPDX-License-Identifier: Apache-2.0 # +# ==================================================================================================================== # +# +"""Test code for pyTooling.""" diff --git a/tests/unit/requirements.txt b/tests/unit/requirements.txt new file mode 100644 index 0000000..3c8d7e7 --- /dev/null +++ b/tests/unit/requirements.txt @@ -0,0 +1 @@ +-r ../requirements.txt