diff --git a/.github/workflows/test_workflow.yml b/.github/workflows/test_workflow.yml new file mode 100644 index 0000000..54f9b50 --- /dev/null +++ b/.github/workflows/test_workflow.yml @@ -0,0 +1,143 @@ +name: Test testflo + +on: + # Trigger on push or pull request events for the master branch + push: + branches: [ master ] + pull_request: + branches: [ master ] + + # Allow running the workflow manually from the Actions tab + workflow_dispatch: + inputs: + debug_enabled: + type: boolean + description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)' + required: false + default: false + +permissions: {} + +jobs: + + tests: + + timeout-minutes: 20 + + strategy: + fail-fast: false + matrix: + include: + # test on Ubuntu + - NAME: Ubuntu Baseline + OS: ubuntu-latest + PY: '3.11' + + # test on MacOS + - NAME: MacOS Baseline + OS: macos-latest + PY: '3.11' + + runs-on: ${{ matrix.OS }} + + name: ${{ matrix.NAME }} + + defaults: + run: + shell: bash -l {0} + + steps: + + - name: Checkout code + uses: actions/checkout@v3 + + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.PY }} + + - name: Install testflo + run: | + python -m pip install --upgrade pip + python -m pip install . + + # Enable tmate debugging of manually-triggered workflows if the input option was provided + # + # To access the terminal through the web-interface: + # 1. Click on the web-browser link printed out in this action from the github + # workflow terminal + # 2. Press cntrl + c in the new tab that opens up to reveal the terminal + # 3. To activate the conda environment run: + # $ source $CONDA/etc/profile.d/conda.sh + # $ conda activate test + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 + if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }} + + - name: Run tests + run: | + cd $HOME + + testflo testflo.tests || RC=$? + + if [[ $RC -ne 1 ]]; then + echo "Expected some tests to fail." + exit 1 + fi + + if [[ ! -n `grep "Ran 26 tests" testflo_report.out` ]]; then + echo "Expected 26 tests." + exit 26 + fi + + if [[ ! -n `grep "Passed: 7" testflo_report.out` ]]; then + echo "Expected 7 tests to pass." + exit 7 + fi + + if [[ ! -n `grep "Failed: 8" testflo_report.out` ]]; then + echo "Expected 8 tests to fail." + exit 8 + fi + + if [[ ! -n `grep "Skipped: 11" testflo_report.out` ]]; then + echo "Expected 11 tests to be skipped." + exit 11 + fi + + - name: Run tests in serial + run: | + cd $HOME + + testflo -n 1 testflo.tests || RC=$? + + if [[ $RC -ne 1 ]]; then + echo "Expected some tests to fail." + exit 1 + fi + + if [[ ! -n `grep "Ran 26 tests using 1 processes" testflo_report.out` ]]; then + echo "Expected 26 tests on one process." + exit 26 + fi + + if [[ ! -n `grep "Passed: 7" testflo_report.out` ]]; then + echo "Expected 7 tests to pass." + exit 7 + fi + + if [[ ! -n `grep "Failed: 8" testflo_report.out` ]]; then + echo "Expected 8 tests to fail." + exit 8 + fi + + if [[ ! -n `grep "Skipped: 11" testflo_report.out` ]]; then + echo "Expected 11 tests to be skipped." + exit 11 + fi + + - name: Notify slack of failure + uses: act10ns/slack@v2.0.0 + with: + webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }} + status: ${{ job.status }} + if: failure() diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..c2e52e3 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,38 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "testflo" +dynamic = ["version"] +description = "A simple flow-based testing framework" +readme = "README.md" +license = "Apache-2.0" +classifiers = [ + "Development Status :: 4 - Beta", + "License :: OSI Approved :: Apache Software License", + "Natural Language :: English", + "Operating System :: MacOS :: MacOS X", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX :: Linux", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: Implementation :: CPython", +] +dependencies = [ + "setuptools", + "coverage>=6.0", +] + +[project.scripts] +testflo = "testflo.main:main" + +[tool.hatch.version] +path = "testflo/__init__.py" + +[tool.hatch.build.targets.sdist] +include = [ + "/testflo", +] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index b88034e..0000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[metadata] -description-file = README.md diff --git a/setup.py b/setup.py deleted file mode 100644 index 1dd7409..0000000 --- a/setup.py +++ /dev/null @@ -1,42 +0,0 @@ -from setuptools import setup - -import re - -from pathlib import Path - -__version__ = re.findall( - r"""__version__ = ["']+([0-9\.\-dev]*)["']+""", - open('testflo/__init__.py').read(), -)[0] - -with open(Path(__file__).parent / "README.md", encoding="utf-8") as f: - long_description = f.read() - -setup(name='testflo', - version=__version__, - description="A simple flow-based testing framework", - long_description=long_description, - long_description_content_type='text/markdown', - classifiers=[ - 'Development Status :: 4 - Beta', - 'License :: OSI Approved :: Apache Software License', - 'Natural Language :: English', - 'Operating System :: MacOS :: MacOS X', - 'Operating System :: POSIX :: Linux', - 'Operating System :: Microsoft :: Windows', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: Implementation :: CPython', - ], - license='Apache 2.0', - install_requires=[ - 'coverage>=6.0' - ], - packages=['testflo'], - entry_points=""" - [console_scripts] - testflo=testflo.main:main - """ - ) diff --git a/testflo/tests/__init__.py b/testflo/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/testflo/test/test_nested_fixtures.py b/testflo/tests/test_nested_fixtures.py similarity index 81% rename from testflo/test/test_nested_fixtures.py rename to testflo/tests/test_nested_fixtures.py index 2049e1d..c82ae58 100644 --- a/testflo/test/test_nested_fixtures.py +++ b/testflo/tests/test_nested_fixtures.py @@ -45,19 +45,19 @@ def test_tcase_grouped_unexpected_success(self): @unittest.skip("skipping 2") def test_tcase_grouped_skip(self): - pass + self.fail("This test should have been skipped.") @unittest.skip("skipping a whole testcase...") class SkippedTestCase2(unittest.TestCase): def test_1(self): - pass + self.fail("This test should have been skipped.") def test_2(self): - pass + self.fail("This test should have been skipped.") def test_3(self): - pass + self.fail("This test should have been skipped.") def test_4(self): - pass + self.fail("This test should have been skipped.") diff --git a/testflo/test/test_testflo.py b/testflo/tests/test_testflo.py similarity index 89% rename from testflo/test/test_testflo.py rename to testflo/tests/test_testflo.py index 4b343d0..9d2841d 100644 --- a/testflo/test/test_testflo.py +++ b/testflo/tests/test_testflo.py @@ -12,7 +12,7 @@ def test_env_var(self): self.assertNotEqual(testflo_running, False) def test_fail(self): - self.fail("failure 1") + self.fail("This test should fail") @unittest.expectedFailure def test_expected_fail_good(self): @@ -24,7 +24,7 @@ def test_unexpected_success(self): @unittest.skip("skipping 1") def test_skip(self): - pass + self.fail("This test should have been skipped.") class TestfloTestCaseWFixture(unittest.TestCase): @@ -60,16 +60,16 @@ def test_tcase_grouped_skip(self): @unittest.skip("skipping a whole testcase...") class SkippedTestCase(unittest.TestCase): def test_1(self): - pass + self.fail("This test should have been skipped.") def test_2(self): - pass + self.fail("This test should have been skipped.") def test_3(self): - pass + self.fail("This test should have been skipped.") def test_4(self): - pass + self.fail("This test should have been skipped.") class TestSubTests(unittest.TestCase):